Camera zoom and tracking

614 views
Skip to first unread message

James Scot

unread,
Sep 16, 2013, 12:30:41 PM9/16/13
to jav...@googlegroups.com
I am using the  OpenCVFrameGrabber to take the snapshot.
The camera that I have is an iBall Camera.
 
I need to be able to zoom in using the OpenCv api and then track to the left to center  the image before taking a snap shot.
 
Are there call available in opencv to achieve the above?
I tried searching and did not get any success?
 
 
 

Samuel Audet

unread,
Sep 17, 2013, 7:12:53 AM9/17/13
to jav...@googlegroups.com
There is a CV_CAP_PROP_ZOOM property, so that should work yes.

You'll need to modify OpenCVFrameGrabber.java a bit to insert that
property, but that shouldn't be too hard.

Samuel

James Scot

unread,
Sep 17, 2013, 10:20:29 AM9/17/13
to jav...@googlegroups.com
So I need to take the  OpenCVFrameGrabber.java and modify the source to insert the property.
Then recreate javacv.jar?
 
I am guessing that it will have to be done in the start() method.
I am not clear how that should be done and what value should the property to be set to zoom in to a certain level.
 
Could you give me a sample code snippet for that?
Also after zooming in the focus needs to be moved left so that the entire image is captured.
How can that be done?
 
James.

James Scot

unread,
Sep 19, 2013, 1:41:25 PM9/19/13
to jav...@googlegroups.com
I tried this to be able to zoom.
 
            com.googlecode.javacv.cpp.opencv_highgui.CvCapture capture = cvCreateCameraCapture(0);
           
            com.googlecode.javacv.cpp.opencv_highgui.cvSetCaptureProperty(capture
                    , com.googlecode.javacv.cpp.opencv_highgui.CV_CAP_PROP_ZOOM, 25000);
           
            com.googlecode.javacv.cpp.opencv_highgui.cvQueryFrame(capture);
 
img = cvQueryFrame(capture);

James Scot

unread,
Sep 19, 2013, 1:47:58 PM9/19/13
to jav...@googlegroups.com
Hi Samuel,
 
Thanks for your earlier reply.
 
Sorry I am posting twice since my earlier reply got posted accidently before I entered all the  information.
 
So, I tried this to be able to zoom in the camera:
 
            com.googlecode.javacv.cpp.opencv_highgui.CvCapture capture = cvCreateCameraCapture(0);
           
            com.googlecode.javacv.cpp.opencv_highgui.cvSetCaptureProperty(

                    capture
                    , com.googlecode.javacv.cpp.opencv_highgui.CV_CAP_PROP_ZOOM, 25000);
           
            com.googlecode.javacv.cpp.opencv_highgui.cvQueryFrame(capture);
           
            img = cvQueryFrame(capture);
 
 
     When doing cvSetCaptureProperty, I tried setting the value of CV_CAP_PROP_ZOOM to different values like:
25000 or 10000 etc.
Still the image that I save to the disk is always the same.
No zoom ever  happens.
Am I doing this correctly? Is this the right way to do it?
 
 
 
 
 

On Monday, September 16, 2013 12:30:41 PM UTC-4, James Scot wrote:

Samuel Audet

unread,
Sep 21, 2013, 9:22:51 AM9/21/13
to jav...@googlegroups.com
On 09/20/2013 02:47 AM, James Scot wrote:
> When doing cvSetCaptureProperty, I tried setting the value of
> CV_CAP_PROP_ZOOM to different values like:
> 25000 or 10000 etc.
> Still the image that I save to the disk is always the same.
> No zoom ever happens.
> Am I doing this correctly? Is this the right way to do it?

That looks alright. So it looks like OpenCV or your camera driver
doesn't support zooming with your camera. It's not uncommon, so there's
nothing unusual about that

Samuel

James Scot

unread,
Sep 21, 2013, 3:25:19 PM9/21/13
to jav...@googlegroups.com
Hi Samuel,

Thanks again for the reply.
The camera supports zooming.
I am saying this since when I use the camera software installed on the machine it has controls that let you zoom and track left right up or down.

Since you say the the code I posted looks alright does it mean that Opencv does not support this feature?
How can I confirm this?

Samuel Audet

unread,
Sep 28, 2013, 10:01:28 PM9/28/13
to jav...@googlegroups.com
Hello,

On 09/22/2013 04:25 AM, James Scot wrote:
> Hi Samuel,
>
> Thanks again for the reply.
> The camera supports zooming.
> I am saying this since when I use the camera software installed on the
> machine it has controls that let you zoom and track left right up or down.
>
> Since you say the the code I posted looks alright does it mean that
> Opencv does not support this feature?
> How can I confirm this?

Well if it works with other applications, but it doesn't work with
OpenCV, it's safe to say that OpenCV doesn't support it!

videoInput also has a couple of functions for zooming, so you could try
that instead of OpenCV:
http://code.google.com/p/javacv/source/browse/src/main/java/com/googlecode/javacv/cpp/videoInputLib.java#271

Samuel
Reply all
Reply to author
Forward
0 new messages