How to write text on frame window in Jetson Utils

Hi

Below is my code

display = jetson.utils.videoOutput() 
detector = jetson.inference.detectNet("ssd-mobilenet-v2", ['--model={}'.format(modelDir), '--labels={}'.format(labelDir),
														   '--input-blob=input_0', '--output-cvg=scores',
														   '--output-bbox=boxes'], configData['Confidence'])
videoFeed = jetson.utils.videoSource('Keyboard.webm')

while True:
	img = videoFeed.Capture()
	imgOut = jetson.utils.cudaAllocMapped(width=img.width * 0.5, height=img.height * 0.5, format=img.format)
	jetson.utils.cudaResize(img, imgOut)
	
	detections = detector.Detect(imgOut)

	display.Render(imgOut)

	display.SetStatus("Network {:.0f} FPS".format(detector.GetNetworkFPS()))

	if not videoFeed.IsStreaming() or not display.IsStreaming():
		break

I am looking for some help on writing some custom text on output frame window, just like the way we do it in opencv using cv2.putText().

Thanks

I got it working with below code:

font = jetson.utils.cudaFont()

and then inside while True, after all inferencing

font.OverlayText(img, img.Width, img.height, "TEXT", 5, 5, font.White, font.Gray40)

Although I have got it working but I am not able to understand how can I reduce the font size of the text

font.OverlayText(img, img.Width, img.height, "TEXT", 5, 5, (255, 0, 0), (0, 0, 0))

Hi @ART97, you can set the font size when you initially create the font like so:

font = jetson.utils.cudaFont( size=32 )

32 pixels is the default size (it’s measured in pixels)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.