Drawing rectangle around detected object using SURF

落花浮王杯 提交于 2019-12-03 03:45:36

If you want to see both images with a bounding rectangle to the second one around the detected object you need to use img_matches array and not image when you draw the lines.

If you want to see only the image with the marked object and not the pair of images (as you define by drawing lines into image), you just need to change your code to:

line( image, scene_corners[0], scene_corners[1], Scalar(0, 255, 0), 4 );

line( image, scene_corners[1], scene_corners[2], Scalar( 0, 255, 0), 4 );

line( image, scene_corners[2], scene_corners[3], Scalar( 0, 255, 0), 4 );

line( image, scene_corners[3], scene_corners[0], Scalar( 0, 255, 0), 4 );

and show the image in a new window

imshow( "Result", image);

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!