Hello,
I need to save the text and rectangle with video frames.
However, when I run the following code, It only records the file and save it.
It does not save the rectangle and text with video frames.
How can I do save the video with text and rectangle?
NOTE:
I have also tried to use opecv videoWriter function but it fails to save.
result = cv2.VideoWriter(‘saveFile_WRITE.avi’,
cv2.VideoWriter_fourcc(*‘MJPG’),
10, (640, 480))
Therefore, I used camera.enable_recording because it saves files. But it fails to save the video with text and rectangle.
Code
filepath = “saveFile.svo”
record_param = sl.RecordingParameters(filepath)
vid = camera.enable_recording(record_param)
while True:
if camera.grab(runtime_params) == sl.ERROR_CODE.SUCCESS:
camera.retrieve_image(image, sl.VIEW.LEFT) # Retrieve left image
camera.retrieve_image(depth_map, sl.VIEW.DEPTH) # Retrieve depth
numpy_image = image.get_data()
numpy_depth_map = depth_map.get_data()
# Using cv2.putText()
new_image = cv2.putText(
img=numpy_image,
text="Save this Text with Video frame",
org=(200, 200),
fontFace=cv2.FONT_HERSHEY_DUPLEX,
fontScale=3.0,
color=(125, 246, 55),
thickness=3
)
cv2.rectangle(numpy_image, (70, 70), (270, 575), (227, 207, 87), 2)
cv2.imshow('image', numpy_image)
cv2.imshow('DEPTH', numpy_depth_map)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
camera.disable_recording()