Skip to main content

Display Object

The Display object implements video display functionality, capable of outputting image data to a monitor via the HDMI interface. This object includes methods such as display, set_img, set_graph_rect, set_graph_word, and close. Detailed descriptions are provided below:

display

【Function Description】

Initializes the display module and configures display parameters.

【Function Declaration】
Display.display(chn, width, height, vot_intf, vot_out_mode)
【Parameter Description】
ParameterDescriptionValue Range
chnDisplay output layer0: Video layer, 2: Graphics layer
widthWidth of the input imageUp to 1920
heightHeight of the input imageUp to 1080
vot_intfVideo interface output resolutionDefault: 0 (1080p)
vot_out_modeVideo output interfaceDefault: 1 (HDMI output)
【Usage】
#create display object
disp = libsrcampy.Display()

#enable display function, resolution: 1080p, interface: HDMI
ret = disp.display(0, 1920, 1080, 0, 1)
【Return Value】
Return ValueDescription
0Success
-1Failure
【Notes】

The HDMI interface resolution on the development board is obtained from the monitor's EDID. Currently, only the following resolutions are supported: 1920x1080, 1280x720, 1024x600, and 800x480. When enabling the display module, ensure that the configured resolution matches the actual resolution of the connected monitor.

【Reference Code】

None

set_img

【Function Description】

Feeds display data into the display module. The data format must be NV12.

【Function Declaration】
Display.set_img(img)
【Parameter Description】
ParameterDescriptionValue Range
imgImage data to be displayedNV12 format
【Usage】

None

【Return Value】
Return ValueDescription
0Success
-1Failure
【Notes】

This interface must be used only after enabling the display functionality via the display interface. The input data must be in NV12 format.

【Reference Code】
import sys, os, time

import numpy as np
import cv2
from hobot_vio import libsrcampy

def test_display():
#create display object
disp = libsrcampy.Display()

#enable display function
ret = disp.display(0, 1920, 1080, 0, 1)
print ("Display display 0 return:%d" % ret)

fo = open("output.img", "rb")
img = fo.read()
fo.close()

#send image data to display
ret = disp.set_img(img)
print ("Display set_img return:%d" % ret)

time.sleep(3)

disp.close()
print("test_display done!!!")

test_display()

set_graph_rect

【Function Description】

Draws a rectangle on the graphics layer of the display module.

【Function Declaration】
Display.set_graph_rect(x0, y0, x1, y1, chn, flush, color, line_width)
【Parameter Description】
ParameterDescriptionValue Range
x0X-coordinate of the top-left corner of the rectangleWithin video frame dimensions
y0Y-coordinate of the top-left corner of the rectangleWithin video frame dimensions
x1X-coordinate of the bottom-right corner of the rectangleWithin video frame dimensions
y1Y-coordinate of the bottom-right corner of the rectangleWithin video frame dimensions
chnGraphics layer channel numberRange: 2–3, default: 2
flushWhether to clear the graphics layer buffer0: No, 1: Yes
colorRectangle colorARGB8888 format
line_widthWidth of the rectangle borderRange: 1–16, default: 4
【Usage】
#enable graph layer 2
ret = disp.display(2)
print ("Display display 2 return:%d" % ret)

#set osd rectangle
ret = disp.set_graph_rect(100, 100, 1920, 200, chn = 2, flush = 1, color = 0xffff00ff)
【Return Value】
Return ValueDescription
0Success
-1Failure
【Notes】

This interface must be used only after enabling the display functionality via the display interface.

【Reference Code】

None

set_graph_word

【Function Description】

Draws text characters on the graphics layer of the display module.

【Function Declaration】
Display.set_graph_word(x, y, str, chn, flush, color, line_width)
【Parameter Description】
ParameterDescriptionValue Range
xX-coordinate of the starting position for textWithin video frame dimensions
yY-coordinate of the starting position for textWithin video frame dimensions
strText string to be drawnGB2312 encoding
chnGraphics layer channel numberRange: 2–3, default: 2
flushWhether to clear the graphics layer buffer0: No, 1: Yes
colorText colorARGB8888 format
line_widthLine width of the text charactersRange: 1–16, default: 1
【Usage】
#enable graph layer 2
ret = disp.display(2)
```print ("Display display 2 return:%d" % ret)

#set osd string
string = "horizon"
ret = disp.set_graph_word(300, 300, string.encode('gb2312'), 2, 0, 0xff00ffff)
print ("Display set_graph_word return:%d" % ret)
【Return Value】
Return ValueDescription
0Success
-1Failure
【Notes】

This API must be used after enabling the display functionality via the display interface.

【Sample Code】

None

close

【Function Description】

Closes the display module.

【Function Declaration】
Display.close()
【Parameter Description】

None

【Usage】

None

【Return Value】
Return ValueDescription
0Success
-1Failure
【Notes】

This API must be used after enabling the display functionality via the display interface.

【Sample Code】

None

bind Interface

【Function Description】

This interface binds the output and input data streams of modules such as Camera, Encoder, Decoder, and Display. Once bound, data automatically flows between the modules without requiring further user intervention. For example, after binding Camera and Display, camera data will be automatically output to the display through the display module without calling additional APIs.

【Function Declaration】
    libsrcampy.bind(src, dst)
【Parameter Description】
ParameterDescriptionValue Range
srcSource data moduleCamera, Encoder, Decoder modules
dstDestination data moduleCamera, Encoder, Decoder, Display modules
【Usage】
#create camera object
cam = libsrcampy.Camera()
ret = cam.open_cam(0, 1, 30, [1920, 1280], [1080, 720])
print("Camera open_cam return:%d" % ret)

#encode start
enc = libsrcampy.Encoder()
ret = enc.encode(0, 1, 1920, 1080)
print("Encoder encode return:%d" % ret)

#bind, input: cam, output: enc
ret = libsrcampy.bind(cam, enc)
print("libsrcampy bind return:%d" % ret)
【Return Value】
Return ValueDescription
0Success
-1Failure
【Notes】

None

【Sample Code】

None

unbind Interface

【Function Description】

Unbinds two previously bound modules.

【Function Declaration】
libsrcampy.unbind(src, dst)
【Parameter Description】
ParameterDescriptionValue Range
srcSource data moduleCamera, Encoder, Decoder modules
dstDestination data moduleCamera, Encoder, Decoder, Display modules
【Usage】
#create camera object
cam = libsrcampy.Camera()
ret = cam.open_cam(0, 1, 30, [1920, 1280], [1080, 720])
print("Camera open_cam return:%d" % ret)

#encode start
enc = libsrcampy.Encoder()
ret = enc.encode(0, 1, 1920, 1080)
print("Encoder encode return:%d" % ret)

#bind, input: cam, output: enc
ret = libsrcampy.bind(cam, enc)
print("libsrcampy bind return:%d" % ret)

#unbind, input: cam, output: enc
ret = libsrcampy.unbind(cam, enc)
print("libsrcampy unbind return:%d" % ret)
【Return Value】
Return ValueDescription
0Success
-1Failure
【Notes】

None

【Sample Code】

None