简体   繁体   中英

How to name each tile in CV2 imshow?

cv2.namedWindow('All cameras', cv2.WINDOW_AUTOSIZE)

top_row = np.concatenate(
    (sensor_data1['rgb_image'], sensor_data4['rgb_image']), axis=1)
lower_row = np.concatenate(
    (sensor_data2['rgb_image'], sensor_data3['rgb_image']), axis=1)
tiled = np.concatenate(
    (top_row, lower_row), axis=0)

cv2.imshow('All cameras', tiled)
cv2.waitKey(1)

My imshow window has now 4 video Streaming from 4 sensors. How can I name each tile with different names?

For eg: Left top as Sensor 1, right top as Sensor 2 inside the imshow?

I do not exactly know, if you can label the tiles directly, because you fabricate somehow a "merged" image matrix with concatenate, so you have to add every border, frame etc. yourself. You might just use cv.putText and calculate the position of the label inside your image:

# importing cv2
import cv2
 
# font
font = cv2.FONT_HERSHEY_SIMPLEX
  
# position of the label
pos = (50, 50)
  
# fontScale
fontScale = 1
   
# Blue color in BGR
color = (255, 0, 0)
  
# Line thickness of 2 px
thickness = 2
   
# Using cv2.putText() method
image = cv2.putText(image, 'MySensorDataNumber1', pos, font, 
                   fontScale, color, thickness, cv2.LINE_AA)

Be aware the 0,0 position is always the bottom left corner of the image, but you can also specify an other one as optional parameter 'bottomLeftOrigin'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM