{"id":360,"date":"2022-08-30T15:00:03","date_gmt":"2022-08-30T15:00:03","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/06\/an-issue-with-cvgetcaptureproperty-on-opencv-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:00:03","modified_gmt":"2022-08-30T15:00:03","slug":"an-issue-with-cvgetcaptureproperty-on-opencv-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/an-issue-with-cvgetcaptureproperty-on-opencv-collection-of-common-programming-errors\/","title":{"rendered":"an issue with cvGetCaptureProperty on opencv-Collection of common programming errors"},"content":{"rendered":"<p>I have a working opencv code that takes feed from my webcam and displays it. (The code is modified from the one here<\/p>\n<p>The only issue is that when I try to print the frames-per-second value, as<\/p>\n<pre><code>int fps = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);\nprintf (\"Frames per Second: %d\\n\",fps);\n<\/code><\/pre>\n<p>-1 gets printed.<\/p>\n<p>Another (side) issue is that there appears to be some run time errors\/warnings<\/p>\n<pre><code>VIDIOC_QUERYMENU: Invalid argument\nVIDIOC_QUERYMENU: Invalid argument\nselect timeout\nHIGHGUI ERROR: V4L2: Unable to get property (5) - Invalid argument\nHIGHGUI ERROR: V4L: Property (2) not supported by device\nHIGHGUI ERROR: V4L2: Unable to get property (1) - Invalid argument\nHIGHGUI ERROR: V4L: Property (2) not supported by device\n<\/code><\/pre>\n<p>But the code does what it&#8217;s supposed to do, ie, display video from the webcam.<\/p>\n<p>Any ideas how to sort out the problems? I am using opencv on Eclipse with CDT on Ubuntu 11.10<\/p>\n<p>Thanks in advance.<\/p>\n<ol>\n<li>\n<p>Judging from the error messages, this sounds like a problem your webcam driver. The error messages are from Video4Linux (V4L or V4L2 in the error messages), which is the part of the Linux kernel that contains webcam drivers. Getting a <code>select()<\/code> failure and the &#8220;not supported by device&#8221; error message probably means that your webcam didn&#8217;t implement this part of the V4L2 API.<\/p>\n<p>You can verify that this is the problem by testing your code with a camera that has a known-good driver. Unfortunately, this is very common in the webcam drivers included in the kernel. Many of them are reverse engineered, so it&#8217;s quite a feat just access the video stream.<\/p>\n<\/li>\n<li>\n<p>Try this for the HIGHGUI ERROR errors:<\/p>\n<pre><code>export LD_PRELOAD=\/usr\/lib\/libv4l\/v4l1compat.so\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-06 03:16:32. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I have a working opencv code that takes feed from my webcam and displays it. (The code is modified from the one here The only issue is that when I try to print the frames-per-second value, as int fps = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FPS); printf (&#8220;Frames per Second: %d\\n&#8221;,fps); -1 gets printed. Another (side) issue is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-360","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/360","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=360"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/360\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}