Set Camera Resolution

261 views
Skip to first unread message

Carlos Antunes

unread,
Dec 29, 2016, 2:12:22 PM12/29/16
to OpenPnP
Hello!

First of all, thank you for all the people that contribute to the development of OpenPnP.

I'm running the latest snapshot of OpenPnP on Linux (Debian) and have an ELP camera capable of doing up to 1920x1080. My preferred resolution is 1280x1024 because it is the most "square". Using OpenCV directly or guvcview, I'm able to go thru all possible resolutions without any problem. However, on OpenPnP, and regardless of the setting, I always get 640x480. Any ideas on how I might force a different resolution?

Thanks!

Carlos

Jason von Nieda

unread,
Dec 29, 2016, 2:44:57 PM12/29/16
to ope...@googlegroups.com
Hi Carlos,

Have you tried setting the Preferred Width and Preferred Height settings? These control the resolution that OpenCV is commanded to use.

Screen Shot 2016-12-29 at 1.43.33 PM.png

Also, when you say it always gets 640x480, where are seeing or measuring that?

Jason


--
You received this message because you are subscribed to the Google Groups "OpenPnP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openpnp/ae4e8a19-4773-4565-9950-ed132d5c9b8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Carlos Antunes

unread,
Dec 29, 2016, 3:10:03 PM12/29/16
to OpenPnP
Hi, Jason!

I'm setting my preferred width and height in the form you posted. With or without restart, the resolution shown on "Show Image Info?" is always 640x480. I get to this menu by right-clicking on the window where the camera image is shown.

Thanks!

Carlos

Jason von Nieda

unread,
Dec 29, 2016, 3:26:31 PM12/29/16
to OpenPnP
Hi Carlos, can you show me the opencv code that works for you? Maybe I am doing something wrong in openpnp.

Carlos A

unread,
Dec 29, 2016, 3:33:46 PM12/29/16
to ope...@googlegroups.com
Jason,

This is what I'm doing, in Python. Nothing out of the ordinary.

cap = cv2.VideoCapture()
cap.open(0)
cap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, 1280)
cap.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, 1024)
while(True):
    ret, img = cap.read()
    # etc...

Carlos

To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+unsubscribe@googlegroups.com.

To post to this group, send email to ope...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openpnp/0253d4af-b004-4604-b5ca-ea222e58e807%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "OpenPnP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openpnp/tryQJbz06aU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openpnp+unsubscribe@googlegroups.com.

To post to this group, send email to ope...@googlegroups.com.

Jason von Nieda

unread,
Dec 29, 2016, 3:59:09 PM12/29/16
to ope...@googlegroups.com
Carlos,


What version of OpenCV do you have installed for your Python bindings? The only things that come to mind are either a difference in version, or possibly the version of OpenCV I distribute may not include the same capture drivers that your local one does, so maybe the one you are hitting from Python gets a capture driver that support properties and the one I have in OpenPnP doesn't. Unfortunately I am not quite sure how to determine what the difference would be. 

Jason


--
You received this message because you are subscribed to a topic in the Google Groups "OpenPnP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openpnp/tryQJbz06aU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openpnp+u...@googlegroups.com.

To post to this group, send email to ope...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "OpenPnP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.

Carlos A

unread,
Dec 29, 2016, 7:25:19 PM12/29/16
to ope...@googlegroups.com
Jason,

I'm running opencv 2.4.9.1 (Debian jessie). I notice that initCamera() is being called from three different locations. Maybe it's being called when the preferred width/height haven't been set yet? I'm afraid I'm too clueless about Java to be of help... Maybe check and log the return values of  fg.fet(Highgui.CV_CAP_PROP_FRAME_WIDTH/HEIGHT) somewhere?

Carlos


To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+unsubscribe@googlegroups.com.

To post to this group, send email to ope...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openpnp/0253d4af-b004-4604-b5ca-ea222e58e807%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "OpenPnP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openpnp/tryQJbz06aU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openpnp+unsubscribe@googlegroups.com.

To post to this group, send email to ope...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "OpenPnP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+unsubscribe@googlegroups.com.

To post to this group, send email to ope...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "OpenPnP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openpnp/tryQJbz06aU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openpnp+unsubscribe@googlegroups.com.

To post to this group, send email to ope...@googlegroups.com.

Jason von Nieda

unread,
Dec 29, 2016, 9:04:05 PM12/29/16
to ope...@googlegroups.com
Hi Carlos,

The feature does work, at least on Mac. I tested a bit earlier today and was able to set my camera to arbitrary resolutions with no problem. 

I've created an issue for this and have included instructions to test. It would be helpful if anyone else running Linux could run the test described in the issue and report their results.


Thanks,
Jason


--
You received this message because you are subscribed to a topic in the Google Groups "OpenPnP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openpnp/tryQJbz06aU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openpnp+u...@googlegroups.com.

To post to this group, send email to ope...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "OpenPnP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "OpenPnP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/openpnp/tryQJbz06aU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to openpnp+u...@googlegroups.com.

To post to this group, send email to ope...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "OpenPnP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.

Jason von Nieda

unread,
Dec 30, 2016, 10:42:39 AM12/30/16
to ope...@googlegroups.com
Carlos,

I've pushed a test version based on comments in the issue. Can you try it out? This version sets the camera resolution before and after opening and it also prints the resulting values to the log. Turn on DEBUG logging to see the output.


Jason

Reply all
Reply to author
Forward
0 new messages