jloyd / javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

Add get source width/height methods to FrameGrabber #80

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
There doesn't seem to be a way to get the frame grabber's source width/height. 
getImageWidth/Height only return something if you've overridden them.

Should be easy to add, at least in FFmpegFrameGrabber.start():

        int width  = getImageWidth()  > 0 ? getImageWidth()  : pCodecCtx.width();
        int height = getImageHeight() > 0 ? getImageHeight() : pCodecCtx.height();

becomes

        int width = getImageWidth();
        if (width == 0) {
            width = pCodecCtx.width();
            setImageWidth(width);
        }

        int height = getImageHeight();
        if (height == 0) {
            height = pCodecCtx.height();
            setImageHeight(height);
        }

Original issue reported on code.google.com by david.cr...@infotrek.net on 30 Jun 2011 at 6:26

GoogleCodeExporter commented 9 years ago
VideoInputFrameGrabber.start() needs at the end:

        if (getImageWidth() == 0) {
             setImageWidth(myVideoInput.getWidth(deviceNumber));
        }

        if (getImageHeight() == 0) {
            setImageHeight(myVideoInput.getHeight(deviceNumber));
        }

Original comment by david.cr...@infotrek.net on 30 Jun 2011 at 7:49

GoogleCodeExporter commented 9 years ago
This may work fine for `FFmpegFrameGrabber` and `VideoInputFrameGrabber`, but 
it does not work for `OpenCVFrameGrabber`. Some devices may also change image 
resolution at any time. The only reliable way to get the width and height is 
simply to take the width and height of the images you get from `grab()`.

Original comment by samuel.a...@gmail.com on 1 Jul 2011 at 3:48