{"id":363,"date":"2022-08-30T15:00:06","date_gmt":"2022-08-30T15:00:06","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/06\/opencv-canny-edge-on-live-video-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:00:06","modified_gmt":"2022-08-30T15:00:06","slug":"opencv-canny-edge-on-live-video-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/opencv-canny-edge-on-live-video-collection-of-common-programming-errors\/","title":{"rendered":"OpenCV Canny Edge on Live Video-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li>\n<p>The Problem is that you are passing a 3 channel image everywere<\/p>\n<pre><code>IplImage* out = cvCreateImage( cvGetSize(frame), IPL_DEPTH_8U, 3 );\n<\/code><\/pre>\n<p>Create other two images of single channel and use those:<\/p>\n<pre><code>IplImage* gray_out = cvCreateImage( cvGetSize(frame), IPL_DEPTH_8U, 1 );\nIplImage* canny_out = cvCreateImage( cvGetSize(frame), IPL_DEPTH_8U, 1 );\n<\/code><\/pre>\n<p>and use it in:<\/p>\n<pre><code>cvSmooth( frame, out, CV_GAUSSIAN, 11, 11 );\ncvCvtColor(out , gray_out, CV_RGB2GRAY);\ncvCanny( gray_out, canny_out, 10, 10, 3 );\n\nif( !frame ) break;\ncvShowImage( \"Edge\", canny_out );\n<\/code><\/pre>\n<p>This works for me:<\/p>\n<pre><code>#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\nusing namespace std;\nusing namespace cv;\n\nint main(int, char**)\n{\n\n    cvNamedWindow(\"Edges\", CV_WINDOW_AUTOSIZE); \nCvCapture* capture = cvCaptureFromCAM(0);\n\nIplImage* frame;\n    while(1) {\n        frame = cvQueryFrame( capture );\n\n        int depth_img =frame-&gt;depth;\n        int height_img =frame-&gt;height;\n        int width_img =frame-&gt;width;\n        int size_img =frame-&gt;imageSize;\n        int nchan_img =frame-&gt;nChannels;\n        int nsize_img =frame-&gt;nSize;\n\n        cout<\/code><\/pre>\n<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2013-11-06 03:16:48. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>The Problem is that you are passing a 3 channel image everywere IplImage* out = cvCreateImage( cvGetSize(frame), IPL_DEPTH_8U, 3 ); Create other two images of single channel and use those: IplImage* gray_out = cvCreateImage( cvGetSize(frame), IPL_DEPTH_8U, 1 ); IplImage* canny_out = cvCreateImage( cvGetSize(frame), IPL_DEPTH_8U, 1 ); and use it in: cvSmooth( frame, out, CV_GAUSSIAN, 11, [&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-363","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/363","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=363"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/363\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}