yoloとrealsenseのdepthの読み取りでruntimeerrorが出てしまいます。
デスクトップPC,Corei5-7400では下記のコードで動くのですが、Lattepandaalphaでは下記のRuntimeerrorが出てしまいます。考えられる原因等ありましたら、教えていただけると幸いです。```python
コード
import
1from darkflow.net.build import TFNet 2import cv2 3import numpy as np 4 5options = {"model": "cfg/yolo.cfg", "load": "bin/yolo.weights", "threshold": 0.1} 6tfnet = TFNet(options) 7 8class_names = ['aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 9 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 10 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 11 'sheep', 'sofa', 'train', 'tvmonitor'] 12 13num_classes = len(class_names) 14class_colors = [] 15for i in range(0, num_classes): 16 hue = 255*i/num_classes 17 col = np.zeros((1,1,3)).astype("uint8") 18 col[0][0][0] = hue 19 col[0][0][1] = 128 20 col[0][0][2] = 255 21 cvcol = cv2.cvtColor(col, cv2.COLOR_HSV2BGR) 22 col = (int(cvcol[0][0][0]), int(cvcol[0][0][1]), int(cvcol[0][0][2])) 23 class_colors.append(col) 24 25config = rs.config() 26config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30) 27config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30) 28 29pipeline = rs.pipeline() 30profile = pipeline.start(config) 31 32try: 33 while True: 34 frames = pipeline.wait_for_frames() 35 depth_frame = frames.get_depth_frame() 36 color_frame = frames.get_color_frame() 37 if not depth_frame or not color_frame: 38 continue 39 40 depth_image = np.asanyarray(depth_frame.get_data()) 41 color_image = np.asanyarray(color_frame.get_data()) 42 43 result = tfnet.return_predict(color_image) 44 45 for item in result: 46 tlx = item['topleft']['x'] 47 tly = item['topleft']['y'] 48 brx = item['bottomright']['x'] 49 bry = item['bottomright']['y'] 50 label = item['label'] 51 meters = depth_frame.get_distance(tlx+int(brx-tlx/2), bry+int(tly-bry/2)) 52 dep = item['confidence'] 53 54 if dep > 0.4: 55 56 for i in class_names: 57 if label == i: 58 class_num = class_names.index(i) 59 break 60 61 box_color = (255, 128, 0) 62 cv2.rectangle(color_image, (tlx, tly), (brx, bry), box_color, 2) 63 64 text = label + " " + ('%.2f' % meters) 65 cv2.rectangle(color_image, (tlx, tly - 15), (tlx + 100, tly + 5), box_color, -1) 66 cv2.putText(color_image, text, (tlx, tly), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0,0,0), 1) 67 68 cv2.imshow("Show FLAME Image", color_image) 69 70 k = cv2.waitKey(10); 71 if k == ord('q'): break; 72 73finally: 74 pipeline.stop() 75 cv2.destroyAllWindows() 76 77<<<<エラー>>>> 78RuntimeError: out of range value for argument "y" 79(RuntimeError: out of range value for argument "x"となる場合あり) 80該当箇所 meters = depth_frame.get_distance(tlx+int(brx-tlx/2), bry+int(tly-bry/2))
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。