2017-11-17 7 views
0

tensorflow object-detection apiで境界ボックスを描画し、正規化座標を使用しない方法はありますか? object_detection_tutorial.ipynbで、デフォルトの座標が正規化座標にあり、箱の形式が[xmin、ymin、xmax、ymax]であることに気付きました。それらを[image_length xmin、image_width ymin、image_length xmax、image_width ymax ]? 私はどのように境界ボックスを描画し、テンソルフローでオブジェクト座標を使用しないのですか?オブジェクト検出api

 boxes[0]=boxes[0]*200 
     boxes[1]=boxes[1]*100 
     boxes[2]=boxes[2]*200 
     boxes[3]=boxes[3]*100 

を使用しようとするが、エラーが起こる:

--------------------------------------------------------------------------- 
IndexError        Traceback (most recent call last) 
<ipython-input-72-efcec9615ee3> in <module>() 
    30     feed_dict={image_tensor: image_np_expanded}) 
    31     boxes[0]=boxes[0]*200 
---> 32     boxes[1]=boxes[1]*100 
    33     boxes[2]=boxes[2]*200 
    34     boxes[3]=boxes[3]*100 
IndexError: index 1 is out of bounds for axis 0 with size 1 
+0

ボックス変数のdimsを確認してください。インデックス0にはイメージ1のbboxがあります。インデックス1には、2番目のndイメージ用のbboxのNx4行列などがあります。 –

答えて

0

あなたが研究/ object_detection/utilsの/ visualization_utils.pyボックスを見れば[0]は、あなたがこれらの座標を掛けたときにXMINないYMINれます100または200で、イメージの境界にまだあることを確認します(im_width、im_height)。

ボックス[0] * 100、ボックス[1] * -200、ボックス[2] * -100、ボックス[3] * 200を試すことができます。これはこのコードに似ています。

ymin = boxes[0]*100 
xmin = boxes[1]*-200 
ymax = boxes[2]*-100 
xmax = boxes[3]*200 

draw = ImageDraw.Draw(image) 
im_width, im_height = image.size 
(left, right, top, bottom) = (xmin * im_width, xmax * im_width, 
           ymin * im_height, ymax * im_height) 

draw.line([(left, top), (left, bottom), (right, bottom), 
       (right, top), (left, top)], width=thickness, fill=color) 
+0

ありがとうございます! –

関連する問題