【发布时间】:2022-01-20 16:32:23
【问题描述】:
我希望我能解释我的问题。我有一个来自英特尔实感摄像头的视频,其中包含深度信息。每当我的相机和地板之间的距离低于某个值时,我都需要绘制一个矩形。我的问题是视频是在循环中逐帧处理的。我编写了一个 if 语句,它在正确的时刻绘制矩形,但是如果下一帧到来并且 if 语句不再填充,我的 recangle 就会消失。我知道为什么(当然;))但是我怎样才能永远“修复”我的矩形在那个位置。所以最后我想有很多recangles。这里有足够多的矩形是我的代码:非常感谢
while True:
frames = pipeline.wait_for_frames()
#Depth_Stream
depth_frame = frames.get_depth_frame()
#depth_color_frame = rs.colorizer().colorize(depth_frame) #Stream Einfärben
depth_color_frame = depth_frame
depth_color_image = np.asanyarray(depth_color_frame.get_data()) #Erstellen Numpy Array
cv2.circle(depth_color_image,(x_Koordinate, y_Koordinate), 10, (0,0,255), 1) #Kreis zeichnen
cv2.imshow("Depth Stream", depth_color_image)
#array_ausgabe.write(np.array_str(depth_color_image)) #Export RGB-Werte für jedes Pixel
#numpy.savetxt('test.out', depth_color_image, )
#RGB_Stream
rgb_frame = frames.get_color_frame()
rgb_color_image = np.asanyarray(rgb_frame.get_data())
cv2.circle(rgb_color_image,(x_Koordinate,y_Koordinate), 10, (0,0,255), 1) #Kreis zeichnen
hight_over_table = korrigierter_abstand_zur_Kamera(x_Koordinate, y_Koordinate) - Abstand_zum_Tisch
if hight_over_table > 0:
cv2.rectangle(rgb_color_image,(x1_bounding_box,y1_bounding_box),(x2_bounding_box,y2_bounding_box),(0,255,0),3)
else: print("test")
cv2.imshow("RGB Stream", rgb_color_image)
key = cv2.waitKey(1)
if key == 27:
#cv2.destroyAllWindows()
break
【问题讨论】:
-
继续画吗?
-
@ChristophRackwitz 继续画是什么意思?