{"id":6269,"date":"2015-06-30T23:54:48","date_gmt":"2015-06-30T14:54:48","guid":{"rendered":"http:\/\/kako.com\/blog\/?p=6269"},"modified":"2015-06-30T23:55:33","modified_gmt":"2015-06-30T14:55:33","slug":"6269","status":"publish","type":"post","link":"http:\/\/kako.com\/blog\/?p=6269","title":{"rendered":"imgctl.dll\u3068OpenCV\u3092\u4f7f\u3063\u3066GIF\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u51fa\u529b\u3059\u308b\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u307f\u305f"},"content":{"rendered":"<p>\u524d\u306b\u3001<a href=\"http:\/\/kako.com\/blog\/?p=4324\">OpenCV\u3067GIF\u306e\u8aad\u307f\u66f8\u304d\u3067\u304d\u306a\u3044\u306e\u3067imgctl.dll\u3092\u4f7f\u3046<\/a>\u3068\u3044\u3046\u306e\u8cb7\u3044\u305f\u3002<br \/>\n\u305d\u308c\u306b\u52a0\u3048\u3066GIF\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306e\u51fa\u529b\u3068\u3044\u3046\u306e\u3082\u4f5c\u3063\u3066\u307f\u305f\u3002<br \/>\n<!--more--><\/p>\n<p>\u30b3\u30fc\u30c9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u3044\u305f\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n#include &lt;windows.h&gt;\r\n#include &lt;stdio.h&gt;\r\n#include &lt;stdlib.h&gt;\r\n#include &quot;imgctl.h&quot;\r\n#include &quot;opencv2\/opencv.hpp&quot;\r\n\r\nint save_GIF_Anime(char *filename,IplImage *image[],int pages,int time1)\r\n{\r\n\tHDIB hDibs[255];\r\n\tBITMAPINFO bmpInfo;\r\n\tunsigned char *bitmapData[255];\r\n\tDWORD ret;\r\n\tint wd,ht;\r\n\tint i,j,p;\r\n\t\r\n\tif (pages&gt;255) { return 1; \/* error: too many pages *\/ }\r\n\tfor (p=0;p&lt;pages;p++) {\r\n\t\twd = image[p]-&gt;width;\r\n\t\tht = image[p]-&gt;height;\r\n\t\tbitmapData[p] = (unsigned char *)malloc(wd*ht*3);\r\n\t\tif (bitmapData[p]==NULL) {\r\n\t\t\treturn 1; \/\/ error\r\n\t\t}\r\n\t\tZeroMemory(&amp;bmpInfo, sizeof(bmpInfo));\r\n\t\tbmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);\r\n\t\tbmpInfo.bmiHeader.biWidth = wd;\r\n\t\tbmpInfo.bmiHeader.biHeight = ht;\r\n\t\tbmpInfo.bmiHeader.biPlanes = 1;\r\n\t\tbmpInfo.bmiHeader.biBitCount = 24;\r\n\t\tbmpInfo.bmiHeader.biCompression = BI_RGB;\r\n\t\tfor (i=0;i&lt;ht;i++) {\r\n\t\t\tfor (j=0;j&lt;wd;j++) {\r\n\t\t\t\tbitmapData[p][ (j+(ht-i-1)*wd)*3  ] = image[p]-&gt;imageData[image[p]-&gt;widthStep*i+j*3];\r\n\t\t\t\tbitmapData[p][ (j+(ht-i-1)*wd)*3+1] = image[p]-&gt;imageData[image[p]-&gt;widthStep*i+j*3+1];\r\n\t\t\t\tbitmapData[p][ (j+(ht-i-1)*wd)*3+2] = image[p]-&gt;imageData[image[p]-&gt;widthStep*i+j*3+2];\r\n\t\t\t}\r\n\t\t}\r\n\t\t\/\/ create HDIB data\r\n\t\thDibs[p] = NULL;\r\n\t\thDibs[p] = CreateDIB(&amp;bmpInfo,bitmapData[p]);\r\n\t}\r\n\t\r\n\t\/\/ AnimeGIF output\r\n\tret = DIBtoGIFAni(filename,hDibs,(DWORD)pages,(WORD)time1);\r\n\t\r\n\tif (!ret) {\r\n\t\tfor (p=0;p&lt;pages;p++) {\r\n\t\t\tDeleteDIB(hDibs[p]);\r\n\t\t}\r\n\t\treturn 1; \/\/ Error: output failed\r\n\t}\r\n\tfor (p=0;p&lt;pages;p++) {\r\n\t\tfree(bitmapData[p]);\r\n\t\tDeleteDIB(hDibs[p]);\r\n\t}\r\n\treturn 0;\r\n}\r\n\r\nint main()\r\n{\r\n\tIplImage *images[255];\r\n\tchar filename1[255];\r\n\tint i,ret;\r\n\tint page_num,timer;\r\n\t\r\n\tpage_num = 10; \/\/ Number of JPEGs\r\n\ttimer = 50;    \/\/ GIF Anime play time per frame  .. (unit == 1\/100sec)\r\n\r\n\t\/\/ load JPEG\r\n\tfor (i=0;i&lt;page_num;i++) {\r\n\t\tsprintf(filename1,&quot;test%03d.jpg&quot;,i);\r\n\t\timages[i] = cvLoadImage(filename1, CV_LOAD_IMAGE_COLOR);\r\n\t\tif (images[i]==NULL) { printf(&quot;Error: file not found.\\n&quot;); return 1; }\r\n\t}\r\n\t\r\n\t\/\/ output to GIF anime\r\n\tret = save_GIF_Anime(&quot;output.gif&quot;,images,page_num,timer);\r\n\tif (ret!=0) { printf(&quot;Error\\n&quot;); return 1; }\r\n\t\r\n\treturn 0;\r\n}\r\n<\/pre>\n<p>\u9023\u756a\u306eJPG\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3001GIF\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306eGIF\u30d5\u30a1\u30a4\u30eb\u3092\u51fa\u529b\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3060\u3002<\/p>\n<p>\u3053\u308c\u3092\u5143\u306b\u3057\u3066\u3001\u5168\u5929\u5468\u30ab\u30e1\u30e9THETA\u306e\u5168\u5929\u5468\u753b\u50cf\u304b\u3089\u98a8\u666f\u3092\u898b\u56de\u3059\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092GIF\u30d5\u30a1\u30a4\u30eb\u306e\u30b5\u30e0\u30cd\u30a4\u30eb\u3068\u3057\u3066\u4f5c\u6210\u3059\u308b\u30bd\u30d5\u30c8\u3068\u3044\u3046\u306e\u3092\u4f5c\u308a\u4e2d\u3060\u3063\u305f\u308a\u3059\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u306b\u3001OpenCV\u3067GIF\u306e\u8aad\u307f\u66f8\u304d\u3067\u304d\u306a\u3044\u306e\u3067imgctl.dll\u3092\u4f7f\u3046\u3068\u3044\u3046\u306e\u8cb7\u3044\u305f\u3002 \u305d\u308c\u306b\u52a0\u3048\u3066GIF\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u306e\u51fa\u529b\u3068\u3044\u3046\u306e\u3082\u4f5c\u3063\u3066\u307f\u305f\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,14],"tags":[],"_links":{"self":[{"href":"http:\/\/kako.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6269"}],"collection":[{"href":"http:\/\/kako.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/kako.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/kako.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/kako.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6269"}],"version-history":[{"count":2,"href":"http:\/\/kako.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6269\/revisions"}],"predecessor-version":[{"id":6271,"href":"http:\/\/kako.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6269\/revisions\/6271"}],"wp:attachment":[{"href":"http:\/\/kako.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/kako.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6269"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/kako.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}