{"id":99,"date":"2008-09-13T01:07:02","date_gmt":"2008-09-12T16:07:02","guid":{"rendered":"http:\/\/www.atinfinity.info\/blog\/archives\/99"},"modified":"2008-09-13T01:59:00","modified_gmt":"2008-09-12T16:59:00","slug":"cvreleaseimage%e3%81%ae%e6%8c%99%e5%8b%95%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"http:\/\/www.atinfinity.info\/blog\/archives\/99","title":{"rendered":"cvReleaseImage\u306e\u6319\u52d5\u306b\u3064\u3044\u3066"},"content":{"rendered":"<p><a href=\"http:\/\/www.atinfinity.info\/wiki\/index.php?OpenCV%2FvideoInput%20Library%E3%81%AB%E3%82%88%E3%82%8B%E3%83%93%E3%83%87%E3%82%AA%E3%82%AD%E3%83%A3%E3%83%97%E3%83%81%E3%83%A3\" target=\"_blank\">OpenCV\/videoInput Library\u306b\u3088\u308b\u30d3\u30c7\u30aa\u30ad\u30e3\u30d7\u30c1\u30e3<\/a>\u306e\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u3064\u3044\u3066\uff0c<br \/>\n<a href=\"http:\/\/d.hatena.ne.jp\/Nilfs\/20080912\/1221212160\" target=\"_blank\">HandyAR\u306e\u30c7\u30e2\u304c\u52d5\u304b\u306a\u3044\u554f\u984c\u306e\u539f\u56e0\u3092\u767a\u898b\u3057\u305f &#8211; \u30b5\u30a4Scripter\u306e\u65c5\u7acb\u3061<\/a>\u306b\u3066\u4ee5\u4e0b\u306e\u6307\u6458\u304c\u3042\u308a\u307e\u3057\u305f\uff0e<\/p>\n<blockquote><p> \u3069\u3053\u306e\u30b5\u30a4\u30c8\u3092\u898b\u3066\u3082\u3001\u3069\u3046\u3082\u602a\u3057\u3044\u30b3\u30fc\u30c9\u3057\u304b\u8f09\u3063\u3066\u3044\u306a\u3044\u3088\u3046\u306b\u898b\u3048\u308b\u3002<\/p>\n<p>cvCreateImage\u5f8c\u306fimageData\u306b\u30a2\u30ed\u30b1\u30fc\u30c8\u3055\u308c\u3066\u3044\u308b\u3093\u3060\u304b\u3089\u3001imageData\u306b\u4ee3\u5165\u3057\u3061\u3083\u3063\u305f\u3089\u89e3\u653e\u3059\u308b\u30a2\u30c9\u30ec\u30b9\u304c\u308f\u304b\u3089\u306a\u3044\u3068\u601d\u3046\u3093\u3060\u3051\u3069\u306a\u3041\u3002<\/p>\n<p>\u3067\u3082\u30e1\u30e2\u30ea\u30fc\u30ea\u30fc\u30af\u306e\u8b66\u544a\u3067\u306a\u3044\u3057\u306a\u3041\u30fb\u30fb\u30fb<\/p><\/blockquote>\n<p>\u7d50\u8ad6\u304b\u3089\u8a00\u3046\u3068\u30e1\u30e2\u30ea\u89e3\u653e\u306b\u3064\u3044\u3066\u554f\u984c\u306f\u7121\u3044\u3067\u3059\uff0e\u3068\u3044\u3046\u3053\u3068\u3067\uff0c<br \/>\n<strike>\u3053\u3061\u3089\u3068\u3057\u3066\u3082\uff0c\u300c\u602a\u3057\u3044\u30b3\u30fc\u30c9\u3068\u65ad\u5b9a\u300d\u3055\u308c\u308b\u306e\u3082\u766a\u306a\u306e\u3067\uff0c<\/strike><br \/>\n\u306a\u305c\u554f\u984c\u7121\u3044\u304b\u306b\u3064\u3044\u3066\u5c11\u3057\u66f8\u3044\u3066\u307f\u307e\u3059\uff0e<\/p>\n<p>\u307e\u305a\uff0ccvReleaseImage\u306e\u5185\u90e8\u3067\u4f55\u3092\u3084\u3063\u3066\u3044\u308b\u304b\u3068\u3044\u3046\u3068\uff0c<br \/>\n\u78ba\u4fdd\u3057\u305f\u30a4\u30e1\u30fc\u30b8\u9818\u57df\u306e\u89e3\u653e\u306e\u305f\u3081\u306bcvReleaseData\u3092\u30b3\u30fc\u30eb\u3057\u3066\u3044\u307e\u3059\uff0e<br \/>\ncxarray.cpp\u306ecvReleaseData\u95a2\u6570\u306e\u4e2d\u8eab\u3092\u4ee5\u4e0b\u306b\u793a\u3057\u307e\u3059\uff0e<\/p>\n<p>[cpp]<br \/>\n\/\/ Deallocates array&#8217;s data<br \/>\nCV_IMPL void<br \/>\ncvReleaseData( CvArr* arr )<br \/>\n{<br \/>\n    CV_FUNCNAME( &#8220;cvReleaseData&#8221; );<\/p>\n<p>    __BEGIN__;<\/p>\n<p>    if( CV_IS_MAT_HDR( arr ) || CV_IS_MATND_HDR( arr ))<br \/>\n    {<br \/>\n        CvMat* mat = (CvMat*)arr;<br \/>\n        cvDecRefData( mat );<br \/>\n    }<br \/>\n    else if( CV_IS_IMAGE_HDR( arr ))<br \/>\n    {<br \/>\n        IplImage* img = (IplImage*)arr;<\/p>\n<p>        if( !CvIPL.deallocate )<br \/>\n        {<br \/>\n            char* ptr = img->imageDataOrigin;<br \/>\n            img->imageData = img->imageDataOrigin = 0;<br \/>\n            cvFree( &#038;ptr );<br \/>\n        }<br \/>\n        else<br \/>\n        {<br \/>\n            CvIPL.deallocate( img, IPL_IMAGE_DATA );<br \/>\n        }<br \/>\n    }<br \/>\n    else<br \/>\n    {<br \/>\n        CV_ERROR( CV_StsBadArg, &#8220;unrecognized or unsupported array type&#8221; );<br \/>\n    }<\/p>\n<p>    __END__;<br \/>\n}<br \/>\n[\/cpp]<\/p>\n<p>\u305d\u306e\u4e2d\u3067\uff0c<br \/>\n[cpp]<br \/>\nif( !CvIPL.deallocate )<br \/>\n{<br \/>\n    char* ptr = img->imageDataOrigin;<br \/>\n    img->imageData = img->imageDataOrigin = 0;<br \/>\n    cvFree( &#038;ptr );<br \/>\n}<br \/>\n[\/cpp]<br \/>\n\u3068\u3044\u3046\u90e8\u5206\u304b\u3089\u308f\u304b\u308b\u3088\u3046\u306b\u5b9f\u969b\u306b\u89e3\u653e\u3059\u308b\u30e1\u30e2\u30ea\u9818\u57df\u306e\u5148\u982d\u30a2\u30c9\u30ec\u30b9\u3068\u3057\u3066\u6307\u5b9a\u3055\u308c\u308b\u306e\u306f<br \/>\nimg->imageDataOrigin\u3067\u3042\u308b\u3053\u3068\u304c\u308f\u304b\u308b\u3068\u601d\u3044\u307e\u3059\uff0e<\/p>\n<p>\u3067\u306f\uff0cimg->imageDataOrigin\u3063\u3066\u4f55\uff1f\u3068\u3044\u3046\u8a71\u306b\u306a\u308b\u306e\u3067\uff0c<br \/>\nIplImage\u69cb\u9020\u4f53\u306b\u3064\u3044\u3066\u4e00\u5ea6\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\uff0e<br \/>\ncxtypes.h\u306eIplImage\u69cb\u9020\u4f53\u306e\u5b9a\u7fa9\u3092\u4ee5\u4e0b\u306b\u793a\u3057\u307e\u3059\uff0e<\/p>\n<p>[cpp]<br \/>\ntypedef struct _IplImage<br \/>\n{<br \/>\n    int  nSize;         \/* sizeof(IplImage) *\/<br \/>\n    int  ID;            \/* version (=0)*\/<br \/>\n    int  nChannels;     \/* Most of OpenCV functions support 1,2,3 or 4 channels *\/<br \/>\n    int  alphaChannel;  \/* ignored by OpenCV *\/<br \/>\n    int  depth;         \/* pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16S,<br \/>\n                           IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_DEPTH_64F are supported *\/<br \/>\n    char colorModel[4]; \/* ignored by OpenCV *\/<br \/>\n    char channelSeq[4]; \/* ditto *\/<br \/>\n    int  dataOrder;     \/* 0 &#8211; interleaved color channels, 1 &#8211; separate color channels.<br \/>\n                           cvCreateImage can only create interleaved images *\/<br \/>\n    int  origin;        \/* 0 &#8211; top-left origin,<br \/>\n                           1 &#8211; bottom-left origin (Windows bitmaps style) *\/<br \/>\n    int  align;         \/* Alignment of image rows (4 or 8).<br \/>\n                           OpenCV ignores it and uses widthStep instead *\/<br \/>\n    int  width;         \/* image width in pixels *\/<br \/>\n    int  height;        \/* image height in pixels *\/<br \/>\n    struct _IplROI *roi;\/* image ROI. if NULL, the whole image is selected *\/<br \/>\n    struct _IplImage *maskROI; \/* must be NULL *\/<br \/>\n    void  *imageId;     \/* ditto *\/<br \/>\n    struct _IplTileInfo *tileInfo; \/* ditto *\/<br \/>\n    int  imageSize;     \/* image data size in bytes<br \/>\n                           (==image->height*image->widthStep<br \/>\n                           in case of interleaved data)*\/<br \/>\n    char *imageData;  \/* pointer to aligned image data *\/<br \/>\n    int  widthStep;   \/* size of aligned image row in bytes *\/<br \/>\n    int  BorderMode[4]; \/* ignored by OpenCV *\/<br \/>\n    int  BorderConst[4]; \/* ditto *\/<br \/>\n    char *imageDataOrigin; \/* pointer to very origin of image data<br \/>\n                              (not necessarily aligned) &#8211;<br \/>\n                              needed for correct deallocation *\/<br \/>\n}<br \/>\nIplImage;<br \/>\n[\/cpp]<\/p>\n<p>\u30b3\u30e1\u30f3\u30c8\u306b\u3082\u3042\u308a\u307e\u3059\u304c\uff0cimageDataOrigin\u306f\uff0ccvCreateImage\u3067\u78ba\u4fdd\u3057\u305f\u30a4\u30e1\u30fc\u30b8\u9818\u57df\u3092\u89e3\u653e\u3059\u308b<br \/>\n\u3053\u3068\u3092\u4fdd\u8a3c\u3059\u308b\u305f\u3081\u306b\u7528\u610f\u3055\u308c\u3066\u3044\u3066\uff0c\u5b9f\u969b\u306bcvCreateImage\u95a2\u6570\u306e\u5185\u90e8\u3067<br \/>\n\u547c\u3070\u308c\u308bcvCreateData\u95a2\u6570\u306e\u4e2d\u3067\uff0c\u30a4\u30e1\u30fc\u30b8\u9818\u57df\u306e\u5272\u308a\u5f53\u3066\u6642\u306b<br \/>\n\u30a4\u30e1\u30fc\u30b8\u9818\u57df\u306e\u5148\u982d\u30a2\u30c9\u30ec\u30b9\u306fimageData\u3068imageDataOrigin\u306e\u4e21\u65b9\u306b\u683c\u7d0d\u3055\u308c\u307e\u3059\uff0e<br \/>\ncvarray.cpp\u306ecvCreateData\u95a2\u6570\u306e\u4e00\u90e8\u3092\u4ee5\u4e0b\u306b\u793a\u3057\u307e\u3059\uff0e<\/p>\n<p>[cpp]<br \/>\nif( !CvIPL.allocateData )<br \/>\n{<br \/>\n    CV_CALL( img->imageData = img->imageDataOrigin =<br \/>\n                        (char*)cvAlloc( (size_t)img->imageSize ));<br \/>\n}<br \/>\n[\/cpp]<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\uff0cimageData\u304c\u5909\u66f4\u3055\u308c\u3066\u3082\uff0cimageDataOrigin\u306b\u30a4\u30e1\u30fc\u30b8\u9818\u57df\u306e\u5148\u982d\u30a2\u30c9\u30ec\u30b9\u304c<br \/>\n\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u306e\u3067\uff0ccvReleaseImage\u3067\u304d\u3061\u3093\u3068\u89e3\u653e\u3055\u308c\u308b\u3053\u3068\u304c\u304a\u308f\u304b\u308a\u3044\u305f\u3060\u3051\u308b\u3068\u601d\u3044\u307e\u3059\uff0e<\/p>\n<p>\u305d\u3093\u306a\u308f\u3051\u3067\uff0cOpenCV\u306e\u5185\u90e8\u3067\u3069\u3046\u306a\u3063\u3066\u3044\u308b\u304b\u3092\u628a\u63e1\u3057\u305f\u4e0a\u3067\u66f8\u3044\u3066\u3044\u308b\u70b9\u3054\u7406\u89e3\u304f\u3060\u3055\u3044\uff0e<br \/>\n\u203b\u8aa4\u89e3\u3092\u751f\u307e\u306a\u3044\u3088\u3046VI.getPixels\u3067\u53d6\u5f97\u3057\u305f\u30a4\u30e1\u30fc\u30b8\u30c7\u30fc\u30bf\u3092memcpy\u4f7f\u3063\u3066\u30b3\u30d4\u30fc\u3059\u308c\u3070<br \/>\n\u3000\u3044\u3044\u3093\u3067\u3057\u3087\u3046\u3051\u3069\uff0c\u30eb\u30fc\u30d7\u4e2d\u306b\u30e1\u30e2\u30ea\u30b3\u30d4\u30fc\u3092\u884c\u3046\u3068\u901f\u5ea6\u304c\u843d\u3061\u305d\u3046\u306a\u306e\u3067\uff0c\u30dd\u30a4\u30f3\u30bf\u306e\u5909\u66f4\u3067\u6e08\u307e\u305b\u3061\u3083\u3063\u3066\u307e\u3059\uff0e<\/p>\n<p>\uff03\u307e\u3041\uff0c\u6307\u6458\u901a\u308a\uff0cC\uff0cC++\u304c\u3042\u308b\u7a0b\u5ea6\u308f\u304b\u308b\u4eba\u306b\u306f\u4e00\u898b\u5371\u306a\u305d\u3046\u306b\u898b\u3048\u308b\u306e\u306f\u4e8b\u5b9f\u306a\u3093\u3067\u3059\u304c\uff0c<br \/>\n\uff03\u3053\u306e\u3088\u3046\u306b\u304d\u3061\u3093\u3068\u5185\u90e8\u52d5\u4f5c\u307e\u3067\u89e3\u8aac\u3059\u308b\u3068\u305d\u308c\u306a\u308a\u306b\u5927\u5909\u3067\uff0c\u521d\u5fc3\u8005\u304c\u305d\u308c\u3092\u8aad\u3080\u3068\u632b\u6298\u3057\u305d\u3046\u306a\u306e\u3067<br \/>\n\uff03\u4eca\u306e\u3068\u3053\u308d\u8aac\u660e\u3092\u7701\u3044\u3066\u3044\u307e\u3059\uff0e\u305d\u306e\u8fba\u306e\u30d0\u30e9\u30f3\u30b9\u3063\u3066\u96e3\u3057\u3044\u3067\u3059\u3088\u306d\u3002\u3002\u3002<br \/>\n\uff03\u4f55\u304b\u826f\u3044\u6848\u304c\u3042\u308c\u3070\u6559\u3048\u3066\u304f\u3060\u3055\u3044\uff0e<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenCV\/videoInput Library\u306b\u3088\u308b\u30d3\u30c7\u30aa\u30ad\u30e3\u30d7\u30c1\u30e3\u306e\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u3064\u3044\u3066\uff0c HandyAR\u306e\u30c7\u30e2\u304c\u52d5\u304b\u306a\u3044\u554f\u984c\u306e\u539f\u56e0\u3092\u767a\u898b\u3057\u305f &#8211; \u30b5\u30a4Scripter\u306e\u65c5\u7acb\u3061\u306b\u3066\u4ee5\u4e0b\u306e\u6307\u6458\u304c\u3042\u308a &hellip; <a href=\"http:\/\/www.atinfinity.info\/blog\/archives\/99\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a>&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"http:\/\/www.atinfinity.info\/blog\/wp-json\/wp\/v2\/posts\/99"}],"collection":[{"href":"http:\/\/www.atinfinity.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.atinfinity.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.atinfinity.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.atinfinity.info\/blog\/wp-json\/wp\/v2\/comments?post=99"}],"version-history":[{"count":0,"href":"http:\/\/www.atinfinity.info\/blog\/wp-json\/wp\/v2\/posts\/99\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.atinfinity.info\/blog\/wp-json\/wp\/v2\/media?parent=99"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.atinfinity.info\/blog\/wp-json\/wp\/v2\/categories?post=99"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.atinfinity.info\/blog\/wp-json\/wp\/v2\/tags?post=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}