亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cvtemplmatch.cpp

?? 將OpenCV移植到DSP上
?? CPP
字號:
/*M///////////////////////////////////////////////////////////////////////////////////////
//
//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
//  By downloading, copying, installing or using the software you agree to this license.
//  If you do not agree to this license, do not download, install,
//  copy or use the software.
//
//
//                        Intel License Agreement
//                For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
//   * Redistribution's of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//
//   * Redistribution's in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//
//   * The name of Intel Corporation may not be used to endorse or promote products
//     derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/

#include "_cv.h"

void
icvCrossCorr( const CvArr* _img, const CvArr* _templ, CvArr* _corr, CvPoint anchor )
{
    const double block_scale = 4.5;
    const int min_block_size = 256;
    CvMat* dft_img = 0;
    CvMat* dft_templ = 0;
    void* buf = 0;
    
    CV_FUNCNAME( "icvCrossCorr" );
    
    __BEGIN__;

    CvMat istub, *img = (CvMat*)_img;
    CvMat tstub, *templ = (CvMat*)_templ;
    CvMat cstub, *corr = (CvMat*)_corr;
    CvMat sstub, dstub, *src, *dst, temp;
    CvSize dftsize, blocksize;
    CvMat* planes[] = { 0, 0, 0, 0 };
    int x, y, i, yofs, buf_size = 0;
    int depth, templ_depth, corr_depth, max_depth = CV_32F, cn, templ_cn, corr_cn;

    CV_CALL( img = cvGetMat( img, &istub ));
    CV_CALL( templ = cvGetMat( templ, &tstub ));
    CV_CALL( corr = cvGetMat( corr, &cstub ));

    if( CV_MAT_DEPTH( img->type ) != CV_8U &&
        CV_MAT_DEPTH( img->type ) != CV_16U &&
        CV_MAT_DEPTH( img->type ) != CV_32F )
        CV_ERROR( CV_StsUnsupportedFormat,
        "The function supports only 8u, 16u and 32f data types" );

    if( !CV_ARE_DEPTHS_EQ( img, templ ) && CV_MAT_DEPTH( templ->type ) != CV_32F )
        CV_ERROR( CV_StsUnsupportedFormat,
        "Template (kernel) must be of the same depth as the input image, or be 32f" );
    
    if( !CV_ARE_DEPTHS_EQ( img, corr ) && CV_MAT_DEPTH( corr->type ) != CV_32F &&
        CV_MAT_DEPTH( corr->type ) != CV_64F )
        CV_ERROR( CV_StsUnsupportedFormat,
        "The output image must have the same depth as the input image, or be 32f/64f" );

    if( (!CV_ARE_CNS_EQ( img, corr ) || CV_MAT_CN(templ->type) > 1) &&
        (CV_MAT_CN( corr->type ) > 1 || !CV_ARE_CNS_EQ( img, templ)) )
        CV_ERROR( CV_StsUnsupportedFormat,
        "The output must have the same number of channels as the input (when the template has 1 channel), "
        "or the output must have 1 channel when the input and the template have the same number of channels" );

    depth = CV_MAT_DEPTH(img->type);
    cn = CV_MAT_CN(img->type);
    templ_depth = CV_MAT_DEPTH(templ->type);
    templ_cn = CV_MAT_CN(templ->type);
    corr_depth = CV_MAT_DEPTH(corr->type);
    corr_cn = CV_MAT_CN(corr->type);
    max_depth = MAX( max_depth, templ_depth );
    max_depth = MAX( max_depth, depth );
    max_depth = MAX( max_depth, corr_depth );
    if( depth > CV_8U )
        max_depth = CV_64F;

    if( img->cols < templ->cols || img->rows < templ->rows )
        CV_ERROR( CV_StsUnmatchedSizes,
        "Such a combination of image and template/filter size is not supported" );

    if( corr->rows > img->rows + templ->rows - 1 ||
        corr->cols > img->cols + templ->cols - 1 )
        CV_ERROR( CV_StsUnmatchedSizes,
        "output image should not be greater than (W + w - 1)x(H + h - 1)" );

    blocksize.width = cvRound(templ->cols*block_scale);
    blocksize.width = MAX( blocksize.width, min_block_size - templ->cols + 1 );
    blocksize.width = MIN( blocksize.width, corr->cols );
    blocksize.height = cvRound(templ->rows*block_scale);
    blocksize.height = MAX( blocksize.height, min_block_size - templ->rows + 1 );
    blocksize.height = MIN( blocksize.height, corr->rows );

    dftsize.width = cvGetOptimalDFTSize(blocksize.width + templ->cols - 1);
    if( dftsize.width == 1 )
        dftsize.width = 2;
    dftsize.height = cvGetOptimalDFTSize(blocksize.height + templ->rows - 1);
    if( dftsize.width <= 0 || dftsize.height <= 0 )
        CV_ERROR( CV_StsOutOfRange, "the input arrays are too big" );

    // recompute block size
    blocksize.width = dftsize.width - templ->cols + 1;
    blocksize.width = MIN( blocksize.width, corr->cols );
    blocksize.height = dftsize.height - templ->rows + 1;
    blocksize.height = MIN( blocksize.height, corr->rows );

    CV_CALL( dft_img = cvCreateMat( dftsize.height, dftsize.width, max_depth ));
    CV_CALL( dft_templ = cvCreateMat( dftsize.height*templ_cn, dftsize.width, max_depth ));

    if( templ_cn > 1 && templ_depth != max_depth )
        buf_size = templ->cols*templ->rows*CV_ELEM_SIZE(templ_depth);

    if( cn > 1 && depth != max_depth )
        buf_size = MAX( buf_size, (blocksize.width + templ->cols - 1)*
            (blocksize.height + templ->rows - 1)*CV_ELEM_SIZE(depth));

    if( (corr_cn > 1 || cn > 1) && corr_depth != max_depth )
        buf_size = MAX( buf_size, blocksize.width*blocksize.height*CV_ELEM_SIZE(corr_depth));

    if( buf_size > 0 )
        CV_CALL( buf = cvAlloc(buf_size) );

    // compute DFT of each template plane
    for( i = 0; i < templ_cn; i++ )
    {
        yofs = i*dftsize.height;

        src = templ;
        dst = cvGetSubRect( dft_templ, &dstub, cvRect(0,yofs,templ->cols,templ->rows));
    
        if( templ_cn > 1 )
        {
            planes[i] = templ_depth == max_depth ? dst :
                cvInitMatHeader( &temp, templ->rows, templ->cols, templ_depth, buf );
            cvSplit( templ, planes[0], planes[1], planes[2], planes[3] );
            src = planes[i];
            planes[i] = 0;
        }

        if( dst != src )
            cvConvert( src, dst );

        if( dft_templ->cols > templ->cols )
        {
            cvGetSubRect( dft_templ, dst, cvRect(templ->cols, yofs,
                          dft_templ->cols - templ->cols, templ->rows) );
            cvZero( dst );
        }
        cvGetSubRect( dft_templ, dst, cvRect(0,yofs,dftsize.width,dftsize.height) );
        cvDFT( dst, dst, CV_DXT_FORWARD + CV_DXT_SCALE, templ->rows );
    }

    // calculate correlation by blocks
    for( y = 0; y < corr->rows; y += blocksize.height )
    {
        for( x = 0; x < corr->cols; x += blocksize.width )
        {
            CvSize csz = { blocksize.width, blocksize.height }, isz;
            int x0 = x - anchor.x, y0 = y - anchor.y;
            int x1 = MAX( 0, x0 ), y1 = MAX( 0, y0 ), x2, y2;
            csz.width = MIN( csz.width, corr->cols - x );
            csz.height = MIN( csz.height, corr->rows - y );
            isz.width = csz.width + templ->cols - 1;
            isz.height = csz.height + templ->rows - 1;
            x2 = MIN( img->cols, x0 + isz.width );
            y2 = MIN( img->rows, y0 + isz.height );
            
            for( i = 0; i < cn; i++ )
            {
                CvMat dstub1, *dst1;
                yofs = i*dftsize.height;

                src = cvGetSubRect( img, &sstub, cvRect(x1,y1,x2-x1,y2-y1) );
                dst = cvGetSubRect( dft_img, &dstub, cvRect(0,0,isz.width,isz.height) );
                dst1 = dst;
                
                if( x2 - x1 < isz.width || y2 - y1 < isz.height )
                    dst1 = cvGetSubRect( dft_img, &dstub1,
                        cvRect( x1 - x0, y1 - y0, x2 - x1, y2 - y1 ));

                if( cn > 1 )
                {
                    planes[i] = dst1;
                    if( depth != max_depth )
                        planes[i] = cvInitMatHeader( &temp, y2 - y1, x2 - x1, depth, buf );
                    cvSplit( src, planes[0], planes[1], planes[2], planes[3] );
                    src = planes[i];
                    planes[i] = 0;
                }

                if( dst1 != src )
                    cvConvert( src, dst1 );

                if( dst != dst1 )
                    cvCopyMakeBorder( dst1, dst, cvPoint(x1 - x0, y1 - y0), IPL_BORDER_REPLICATE );

                if( dftsize.width > isz.width )
                {
                    cvGetSubRect( dft_img, dst, cvRect(isz.width, 0,
                          dftsize.width - isz.width,dftsize.height) );
                    cvZero( dst );
                }

                cvDFT( dft_img, dft_img, CV_DXT_FORWARD, isz.height );
                cvGetSubRect( dft_templ, dst,
                    cvRect(0,(templ_cn>1?yofs:0),dftsize.width,dftsize.height) );

                cvMulSpectrums( dft_img, dst, dft_img, CV_DXT_MUL_CONJ );
                cvDFT( dft_img, dft_img, CV_DXT_INVERSE, csz.height );

                src = cvGetSubRect( dft_img, &sstub, cvRect(0,0,csz.width,csz.height) );
                dst = cvGetSubRect( corr, &dstub, cvRect(x,y,csz.width,csz.height) );

                if( corr_cn > 1 )
                {
                    planes[i] = src;
                    if( corr_depth != max_depth )
                    {
                        planes[i] = cvInitMatHeader( &temp, csz.height, csz.width, corr_depth, buf );
                        cvConvert( src, planes[i] );
                    }
                    cvMerge( planes[0], planes[1], planes[2], planes[3], dst );
                    planes[i] = 0;                    
                }
                else
                {
                    if( i == 0 )
                        cvConvert( src, dst );
                    else
                    {
                        if( max_depth > corr_depth )
                        {
                            cvInitMatHeader( &temp, csz.height, csz.width, corr_depth, buf );
                            cvConvert( src, &temp );
                            src = &temp;
                        }
                        cvAcc( src, dst );
                    }
                }
            }
        }
    }

    __END__;

    cvReleaseMat( &dft_img );
    cvReleaseMat( &dft_templ );
    cvFree( &buf );
}

/* End of file. */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
天天综合天天做天天综合| 国产夜色精品一区二区av| 日本中文在线一区| 久久久精品日韩欧美| 91美女视频网站| 日本欧美韩国一区三区| 国产午夜精品福利| 欧美三级一区二区| 国产成人一区在线| 亚洲福中文字幕伊人影院| 久久午夜羞羞影院免费观看| 国产成人在线免费| 丝瓜av网站精品一区二区| 国产精品传媒入口麻豆| 欧美一区二区三区视频免费播放 | 亚洲一二三四在线| 久久综合色8888| 欧美日韩亚洲综合| 国产高清无密码一区二区三区| 一个色综合av| 国产精品人人做人人爽人人添| 欧美日本一区二区三区四区 | 播五月开心婷婷综合| 日韩成人dvd| 国产精品成人在线观看| 日韩精品专区在线影院观看| 在线亚洲欧美专区二区| 国产精品一区免费视频| 青青草国产成人av片免费| 亚洲欧美一区二区视频| 久久精品水蜜桃av综合天堂| 日韩视频一区二区在线观看| 91国偷自产一区二区使用方法| 麻豆91在线观看| 亚洲一区二区三区免费视频| 中文字幕乱码日本亚洲一区二区| 日韩一卡二卡三卡| 欧美日韩在线直播| 91猫先生在线| 成人福利视频网站| 成人一区二区三区在线观看| 国产一区二区三区免费观看| 日本不卡在线视频| 日韩精品电影在线| 欧美精品一区二区高清在线观看| 91网站最新网址| 成人手机电影网| 国产成人免费视频| 极品少妇xxxx精品少妇| 免费成人av在线| 日韩黄色免费电影| 亚洲va国产天堂va久久en| 亚洲高清一区二区三区| 亚洲国产精品天堂| 中文字幕一区二区三区四区不卡| 久久久天堂av| 国产清纯白嫩初高生在线观看91| 久久精品亚洲精品国产欧美kt∨| 久久久精品影视| 久久精品亚洲麻豆av一区二区 | 极品销魂美女一区二区三区| 九九视频精品免费| 国产一区欧美日韩| 国产麻豆日韩欧美久久| 国产精品夜夜嗨| 成人一区二区三区视频| av欧美精品.com| 欧美亚洲一区二区在线| 欧美午夜不卡视频| 日本道精品一区二区三区| 在线中文字幕一区| 欧美日韩亚洲丝袜制服| 日韩美女视频在线| 久久精品综合网| 亚洲图片另类小说| 爽好多水快深点欧美视频| 久国产精品韩国三级视频| 国产精品一区二区视频| 成人黄色电影在线| 欧美在线看片a免费观看| 欧美高清视频在线高清观看mv色露露十八 | 精品国产伦一区二区三区观看体验| 精品国产a毛片| 国产精品视频九色porn| 亚洲综合在线第一页| 亚洲一区在线观看视频| 亚洲自拍另类综合| 蜜臀精品久久久久久蜜臀 | 国产亚洲综合在线| 1024亚洲合集| 日本不卡不码高清免费观看| 国产aⅴ精品一区二区三区色成熟| 91偷拍与自偷拍精品| 欧美老肥妇做.爰bbww| 久久久精品欧美丰满| 亚洲精品你懂的| 五月婷婷综合在线| 国产精品66部| 欧美亚州韩日在线看免费版国语版| 欧美日韩亚洲高清一区二区| 久久久久久久久久久久久女国产乱| 亚洲三级电影网站| 美脚の诱脚舐め脚责91| 成人激情动漫在线观看| 欧美日韩黄色影视| 欧美国产日韩精品免费观看| 亚洲欧美日韩精品久久久久| 久久精品国产99久久6| 色综合网站在线| 精品国产第一区二区三区观看体验| 中文字幕精品三区| 日本中文字幕一区| 色综合久久久久久久| 久久久美女艺术照精彩视频福利播放| 1000部国产精品成人观看| 蜜桃一区二区三区在线| 91麻豆福利精品推荐| 日韩精品一区二区三区在线播放| 亚洲欧洲av另类| 国产九色精品成人porny| 一本久久a久久免费精品不卡| 久久在线观看免费| 五月婷婷综合激情| 欧美电视剧免费全集观看| 欧美私模裸体表演在线观看| 国产精品无人区| 久久电影网站中文字幕| 在线欧美日韩国产| 国产精品欧美一级免费| 久久精品国产亚洲一区二区三区| 日本韩国一区二区三区| 国产日韩亚洲欧美综合| 极品少妇xxxx精品少妇偷拍| 欧美一区二区精品| 爽好多水快深点欧美视频| 91国偷自产一区二区使用方法| 国产亚洲精品福利| 国产一区二区三区四区五区美女| 91精品一区二区三区久久久久久 | 蜜桃一区二区三区在线| 欧美日韩在线综合| 亚洲卡通动漫在线| 成人综合婷婷国产精品久久| 91在线国产福利| 亚洲欧美视频在线观看视频| 色综合久久综合网欧美综合网| 一区二区三区精品视频在线| 欧美三级在线播放| 日韩av一区二区三区四区| 欧美成人乱码一区二区三区| 韩国欧美国产一区| 国产精品人成在线观看免费| 色婷婷综合久久| 亚洲第一福利一区| 91麻豆精品久久久久蜜臀| 久久精品国产在热久久| 久久久.com| 日本道色综合久久| 全国精品久久少妇| 国产欧美日韩亚州综合| 91在线精品一区二区三区| 亚洲国产cao| 2017欧美狠狠色| 色综合久久天天综合网| 日韩精品一二三四| 国产片一区二区| 在线观看成人免费视频| 免播放器亚洲一区| 国产精品污网站| 欧美视频在线一区二区三区| 久久国产免费看| 综合激情成人伊人| 日韩一区二区三区视频在线| 成人免费高清在线| 视频一区中文字幕国产| 日本一区二区动态图| 欧美日韩在线观看一区二区| 国产精品夜夜嗨| 五月婷婷激情综合网| 久久这里只精品最新地址| 在线看国产一区| 国产综合色产在线精品| 亚洲午夜久久久久中文字幕久| 欧美精品一区二区三区久久久 | av成人老司机| 老司机精品视频线观看86| 日韩一区欧美一区| 日韩一区二区影院| 99免费精品在线| 久久www免费人成看片高清| 亚洲激情av在线| 久久精品视频免费观看| 9191久久久久久久久久久| 91亚洲午夜精品久久久久久| 激情五月婷婷综合网| 亚洲综合色区另类av| 国产精品丝袜在线| 日韩午夜精品电影| 欧美性做爰猛烈叫床潮| 99久久伊人久久99|