{"id":991,"date":"2011-05-06T12:59:06","date_gmt":"2011-05-06T03:29:06","guid":{"rendered":"http:\/\/www.clearchain.com\/blog\/?p=991"},"modified":"2011-05-06T12:59:06","modified_gmt":"2011-05-06T03:29:06","slug":"libdc1394_video_set_mode-doesnt-change-the-mode-a-solution","status":"publish","type":"post","link":"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution","title":{"rendered":"libdc1394_video_set_mode doesn&#8217;t change the mode &#8211; A solution!"},"content":{"rendered":"<p><em>This article details a reason libdc1394_video_set_mode\/libdc1394_video_set_framerate\u00a0 may not work.<\/em><\/p>\n<p>Whilst working on an application that makes use of a 1394a\/firewire  camera I found a strange bug\/feature with <a href=\"http:\/\/damien.douxchamps.net\/ieee1394\/libdc1394\/\">libdc1394<\/a>. The problem was  dc1394 was being used to the mode of the camera to 800&#215;600 resolution.  However, when querying the frame size after dequeuing the frame, the  size was only 640&#215;480. Ie: See the below snippits:<\/p>\n<pre lang=\"c\">..\r\ndc1394error_t result = dc1394_video_set_mode( this->camera, DC1394_VIDEO_MODE_800x600_RGB8);\r\nif( result != DC1394_SUCCESS )\r\nexit(0);\r\n\r\n....\r\ndc1394video_frame_t *frame=NULL;\r\ndc1394error_t result;\r\n\r\n\/\/ capture one frame\r\nresult = dc1394_capture_dequeue( this->camera, DC1394_CAPTURE_POLICY_WAIT, &frame );\r\nif( result != DC1394_SUCCESS )\r\nexit(0);\r\n\r\n\/\/ Allocate image memory if required\r\nif( this->lastFrame.image == NULL ){\r\nmemcpy(this->lastFrame,frame, sizeof(dc1394video_frame_t));\r\nthis->lastFrame.image = (uint8_t *)malloc(frame->total_bytes * sizeof(uint8_t));\r\n\r\n..<\/pre>\n<p>At this point total_bytes was 921600 which works out to be 640x480x3 (RGB);<\/p>\n<p>I was stumped. I asked for one mode and got another back. All with no errors what so ever from libdc1394.<\/p>\n<p>After over an hour of debugging, google searching and more,\u00a0 I eventually found the reason.\u00a0 The comment that ended up in the code explains the cause:<\/p>\n<pre lang=\"c\">\/\/ Shutdown any isotransports that are setup for the camera.\r\n\/\/ It turns out that libDC1394 will quite happily let you set modes,\r\n\/\/ framerates, etc but if there is an iso stream running none of them\r\n\/\/ will actually take affect. Hence you can set a 800x600 res and get\r\n\/\/ back 640x480 video frame - really nice libdc1394. It could at least\r\n\/\/ indicate there was a active stream when setting the mode!\r\n\/\/ Anyway to deal with this we force the camera to stop capturing\r\n\/\/ before we change the settings, if the camera was capturing prior to\r\n\/\/ setConfiguration being called, we restart the capture<\/pre>\n<p>So the solution is to make sure the iso transmission stream has been shutdown. this can be achieved using:<\/p>\n<pre lang=\"c\">dc1394_video_set_transmission( this->camera, DC1394_OFF );\r\ndc1394_capture_stop( this->camera );<\/pre>\n<p>An easy fix but certainly an annoying setup. I&#8217;ve not tested it but I&#8217;m guessing many of the other functions:<\/p>\n<ul>\n<li>dc1394_video_set_framerate<\/li>\n<li>dc1394_video_set_iso_speed<\/li>\n<li>dc1394_feature_set_mode<\/li>\n<li>dc1394_video_set_one_shot<\/li>\n<\/ul>\n<p>are also affected.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article details a reason libdc1394_video_set_mode\/libdc1394_video_set_framerate\u00a0 may not work. Whilst working on an application that makes use of a 1394a\/firewire camera I found a strange bug\/feature with libdc1394. The problem was dc1394 was being used to the mode of the camera to 800&#215;600 resolution. However, when querying the frame size after dequeuing the frame, the<a href=\"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution\"> <font size=-2>[..more..]<\/font><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21,7],"tags":[361,367,338,365,359,360,362,366,363,364],"class_list":["post-991","post","type-post","status-publish","format-standard","hentry","category-opensource","category-programming","tag-361","tag-broken","tag-crash","tag-different-resolution","tag-firewire","tag-ieee1394","tag-libdc1394","tag-libdc1394_video_set_mode","tag-mode-not-set","tag-video-mode-problem"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>libdc1394_video_set_mode doesn&#039;t change the mode - A solution! - ClearChain<\/title>\n<meta name=\"description\" content=\"This article details a reason libdc1394_video_set_mode\/libdc1394_video_set_framerate\u00a0 may not work. Whilst working on an application that makes use of a\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benjamin Close\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution\"},\"author\":{\"name\":\"Benjamin Close\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/aef6faa2c32188398139db9270ca1c98\"},\"headline\":\"libdc1394_video_set_mode doesn&#8217;t change the mode &#8211; A solution!\",\"datePublished\":\"2011-05-06T03:29:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution\"},\"wordCount\":208,\"commentCount\":0,\"keywords\":[\"1394\",\"broken\",\"crash\",\"different resolution\",\"firewire\",\"ieee1394\",\"libdc1394\",\"libdc1394_video_set_mode\",\"mode not set\",\"video mode problem\"],\"articleSection\":[\"OpenSource\",\"Programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution\",\"url\":\"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution\",\"name\":\"libdc1394_video_set_mode doesn't change the mode - A solution! - ClearChain\",\"isPartOf\":{\"@id\":\"https:\/\/www.clearchain.com\/blog\/#website\"},\"datePublished\":\"2011-05-06T03:29:06+00:00\",\"author\":{\"@id\":\"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/aef6faa2c32188398139db9270ca1c98\"},\"description\":\"This article details a reason libdc1394_video_set_mode\/libdc1394_video_set_framerate\u00a0 may not work. Whilst working on an application that makes use of a\",\"breadcrumb\":{\"@id\":\"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.clearchain.com\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"libdc1394_video_set_mode doesn&#8217;t change the mode &#8211; A solution!\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/#website\",\"url\":\"https:\/\/www.clearchain.com\/blog\/\",\"name\":\"ClearChain\",\"description\":\"-= Daily Happenings =-\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.clearchain.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/aef6faa2c32188398139db9270ca1c98\",\"name\":\"Benjamin Close\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/19dca0aa372edfa901b93c556dfda2e78ad4434558fe4d139598e086315d714a?s=96&d=mm&r=pg\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/19dca0aa372edfa901b93c556dfda2e78ad4434558fe4d139598e086315d714a?s=96&d=mm&r=pg\",\"caption\":\"Benjamin Close\"},\"sameAs\":[\"http:\/\/www.clearchain.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"libdc1394_video_set_mode doesn't change the mode - A solution! - ClearChain","description":"This article details a reason libdc1394_video_set_mode\/libdc1394_video_set_framerate\u00a0 may not work. Whilst working on an application that makes use of a","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution","twitter_misc":{"Written by":"Benjamin Close","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution#article","isPartOf":{"@id":"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution"},"author":{"name":"Benjamin Close","@id":"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/aef6faa2c32188398139db9270ca1c98"},"headline":"libdc1394_video_set_mode doesn&#8217;t change the mode &#8211; A solution!","datePublished":"2011-05-06T03:29:06+00:00","mainEntityOfPage":{"@id":"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution"},"wordCount":208,"commentCount":0,"keywords":["1394","broken","crash","different resolution","firewire","ieee1394","libdc1394","libdc1394_video_set_mode","mode not set","video mode problem"],"articleSection":["OpenSource","Programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution","url":"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution","name":"libdc1394_video_set_mode doesn't change the mode - A solution! - ClearChain","isPartOf":{"@id":"https:\/\/www.clearchain.com\/blog\/#website"},"datePublished":"2011-05-06T03:29:06+00:00","author":{"@id":"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/aef6faa2c32188398139db9270ca1c98"},"description":"This article details a reason libdc1394_video_set_mode\/libdc1394_video_set_framerate\u00a0 may not work. Whilst working on an application that makes use of a","breadcrumb":{"@id":"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.clearchain.com\/blog\/posts\/libdc1394_video_set_mode-doesnt-change-the-mode-a-solution#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.clearchain.com\/blog"},{"@type":"ListItem","position":2,"name":"libdc1394_video_set_mode doesn&#8217;t change the mode &#8211; A solution!"}]},{"@type":"WebSite","@id":"https:\/\/www.clearchain.com\/blog\/#website","url":"https:\/\/www.clearchain.com\/blog\/","name":"ClearChain","description":"-= Daily Happenings =-","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.clearchain.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/aef6faa2c32188398139db9270ca1c98","name":"Benjamin Close","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/19dca0aa372edfa901b93c556dfda2e78ad4434558fe4d139598e086315d714a?s=96&d=mm&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/19dca0aa372edfa901b93c556dfda2e78ad4434558fe4d139598e086315d714a?s=96&d=mm&r=pg","caption":"Benjamin Close"},"sameAs":["http:\/\/www.clearchain.com"]}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/posts\/991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/comments?post=991"}],"version-history":[{"count":7,"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/posts\/991\/revisions"}],"predecessor-version":[{"id":998,"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/posts\/991\/revisions\/998"}],"wp:attachment":[{"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/media?parent=991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/categories?post=991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/tags?post=991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}