質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
YOLO

YOLOとは、画像検出および認識用ニューラルネットワークです。CベースのDarknetというフレームワークを用いて、画像や動画からオブジェクトを検出。リアルタイムでそれが何になるのかを認識し、分類することができます。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Q&A

解決済

1回答

3270閲覧

yoloとrealsenseのdepthの読み取りでruntimeerrorが出てしまいます。

退会済みユーザー

退会済みユーザー

総合スコア0

YOLO

YOLOとは、画像検出および認識用ニューラルネットワークです。CベースのDarknetというフレームワークを用いて、画像や動画からオブジェクトを検出。リアルタイムでそれが何になるのかを認識し、分類することができます。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

0グッド

0クリップ

投稿2019/11/23 15:42

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))

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

meters = depth_frame.get_distance(tlx+int(brx-tlx/2), bry+int(tly-bry/2))

の表記()を適切にすることで解決した。

投稿2020/01/06 15:13

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問