문제

I tried to draw a polygon shape on the video frame. Like this:

boxPolygon = [1, 1;...                           % top-left
        size(boxImage, 2), 1;...                 % top-right
        size(boxImage, 2), size(boxImage, 1);... % bottom-right
        1, size(boxImage, 1);...                 % bottom-left
        1, 1];                   % top-left again to close the polygon
newBoxPolygon = transformPointsForward(tform, boxPolygon);

Poly = [newBoxPolygon(1,1) newBoxPolygon(1,2) newBoxPolygon(2,1) newBoxPolygon(2,2) ...
        newBoxPolygon(3,1) newBoxPolygon(3,2) newBoxPolygon(4,1) newBoxPolygon(4,2)...
        newBoxPolygon(5,1) newBoxPolygon(5,2)];
sceneImage = insertShape(sceneImage, 'Polygon', Poly, 'Color', 'green');
step(hVideoOut, sceneImage);

After that, I recieved an error: Error using vision.VideoPlayer/step Changing the size on input 1 is not allowed without first calling the release() method.

If I delete function 'insertShape', than everything is fine, except that the figure is not drawn.

도움이 되었습니까?

해결책

My guess would be that you are working with grayscale video, and when nothing is detected you are passing a grayscale image to the video player. However, insertShape returns an RGB image, because you are inserting a green polygon into it. The problem is that once you call the step method of vision.VideoPlayer, you cannot change the size of image that you pass into it on subsequent calls. So you have to make sure that you always display an RGB image, even if nothing is detected. You can either use RGB video, or you can create a 3-plane image by replicating your grayscale image 3 times (e. g. using cat(3, sceneImage, sceneImage, sceneImage).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top