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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? agesturerecognition.cpp

?? 微軟的基于HMM的人臉識(shí)別原代碼, 非常經(jīng)典的說(shuō)
?? CPP
字號(hào):
/*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 "CvTest.h"
#include "ats.h"
#include "stdio.h"

static char cTestName[] = "Gesture Recognition";

static char cTestClass[] = "Algorithm";

static char *cFuncName[] = 
{
    "cvGestureRecognition"
     
};
char data_path[1000];

static int aGestureRecognition(void)
{       
    IplImage *image, *imagew, *image_rez, *mask_rez, *image_hsv, *img_p[2],*img_v,
             *init_mask_ver = 0, *final_mask_ver = 0;
    CvPoint3D32f *pp, p;

    CvPoint pt;
    CvSize2D32f fsize;
    CvPoint3D32f center, cf;
    IplImage *image_mask, *image_maskw;
    
    CvSize size;
    CvHistogram *hist, *hist_mask;

    int width, height;
    int k_points, k_indexs;
    int warpFlag, interpolate;

    int hdim[2] = {20, 20};
    
    double coeffs[3][3], rect[2][2], rez = 0, eps_rez = 2.5, rez_h;
    float *thresh[2];
    float hv[3];
    
    float reps, aeps, ww;
    float line[6], in[3][3], h[3][3];
    float cx, cy, fx, fy;

    static char num[4]; 
    
    char *name_image;  
    char *name_range_image;
    char *name_verify_data;
    char *name_init_mask_very;
    char *name_final_mask_very;

    CvSeq *numbers;
    CvSeq *points;
    CvSeq *indexs;
        
    CvMemStorage *storage;
    CvRect hand_roi, hand_roi_trans;
    
    int i,j, lsize, block_size = 1000, flag;
    int code;

    FILE *filin, *fil_ver;

/* read tests params */

    code = TRS_OK;

/*  define input information    */
    strcpy (num, "001"); 

    lsize = strlen(data_path)+12;
    name_verify_data = (char*)trsmAlloc(lsize);
    name_range_image = (char*)trsmAlloc(lsize);
    name_image = (char*)trsmAlloc(lsize);

    name_init_mask_very = (char*)trsmAlloc(lsize);
    name_final_mask_very = (char*)trsmAlloc(lsize);

/*  define input range_image file path        */
    strcpy(name_range_image, data_path);
    strcat(name_range_image, "rpts");
    strcat(name_range_image, num);
    strcat(name_range_image, ".txt");

/*  define input image file path        */
    strcpy(name_image, data_path);
    strcat(name_image, "real");
    strcat(name_image, num);
    strcat(name_image, ".bmp");

/*  define verify data file path        */
    strcpy(name_verify_data, data_path);
    strcat(name_verify_data, "very");
    strcat(name_verify_data, num);
    strcat(name_verify_data, ".txt");

/*  define verify init mask file path    */
    strcpy(name_init_mask_very, data_path);
    strcat(name_init_mask_very, "imas");
    strcat(name_init_mask_very, num);
    strcat(name_init_mask_very, ".bmp");

/*  define verify final mask file path    */
    strcpy(name_final_mask_very, data_path);
    strcat(name_final_mask_very, "fmas");
    strcat(name_final_mask_very, num);
    strcat(name_final_mask_very, ".bmp");

    filin = fopen(name_range_image,"r");
    fil_ver = fopen(name_verify_data,"r");

    fscanf( filin, "\n%d %d\n", &width, &height);
    printf("width=%d height=%d  reading testing data...", width,height);

    OPENCV_CALL( storage = cvCreateMemStorage ( block_size ) );
    OPENCV_CALL( points = cvCreateSeq( CV_SEQ_POINT3D_SET, sizeof(CvSeq),
                            sizeof(CvPoint3D32f), storage ) );
    OPENCV_CALL (indexs = cvCreateSeq( CV_SEQ_POINT_SET, sizeof(CvSeq),
                            sizeof(CvPoint), storage ) );

    pp = 0;
    
/*  read input image from file   */   
    image = atsCreateImageFromFile( name_image );
    if(image == NULL)   {code = TRS_FAIL; goto m_exit;}

/*  read input 3D points from input file        */
    for (i = 0; i < height; i++)
    {
        for (j = 0; j < width; j++)    
        {
            fscanf( filin, "%f %f %f\n", &p.x, &p.y, &p.z);
            if(/*p.x != 0 || p.y != 0 ||*/ p.z != 0)
            {
                OPENCV_CALL(cvSeqPush(points, &p));
                pt.x = j; pt.y = i;
                OPENCV_CALL(cvSeqPush(indexs, &pt));
                               
            }
        }
    }

    k_points = points->total;
    k_indexs = indexs->total;

/*   convert sequence to array          */
    pp = (CvPoint3D32f*)trsmAlloc(k_points * sizeof(CvPoint3D32f));
    OPENCV_CALL(cvCvtSeqToArray(points, pp ));

/*  find 3D-line      */

    reps = (float)0.1;
    aeps = (float)0.1;
    ww = (float)0.08;

    OPENCV_CALL( cvFitLine3D(pp, k_points, CV_DIST_WELSCH, &ww, reps, aeps, line ));

/*  find hand location      */
    flag = -1;
    fsize.width = fsize.height = (float)0.22;  //   (hand size in m)

    numbers = NULL;
    OPENCV_CALL( cvFindHandRegion (pp, k_points, indexs,line, fsize,
                      flag,&center,storage, &numbers));

/*   read verify data    */
    fscanf( fil_ver, "%f %f %f\n", &cf.x, &cf.y, &cf.z);
    rez+= cvSqrt((center.x - cf.x)*(center.x - cf.x)+(center.y - cf.y)*(center.y - cf.y)+
         (center.z - cf.z)*(center.z - cf.z))/3.;
    
/*    create hand mask            */
    size.height = height;
    size.width = width;
    OPENCV_CALL( image_mask = cvCreateImage(size, IPL_DEPTH_8U, 1) ); 

    OPENCV_CALL( cvCreateHandMask(numbers, image_mask, &hand_roi) );

/*  read verify initial image mask                  */
    init_mask_ver = atsCreateImageFromFile( name_init_mask_very );
    if(init_mask_ver == NULL)   {code = TRS_FAIL; goto m_exit;}
    
    rez+= iplNorm(init_mask_ver, image_mask, IPL_L2) / (width*height+0.);

/*  calculate homographic transformation matrix            */
    cx = (float)(width / 2.);
    cy = (float)(height / 2.);
    fx = fy = (float)571.2048;

/* define intrinsic camera parameters                      */
    in[0][1] = in[1][0] = in[2][0] = in[2][1] = 0;
    in[0][0] = fx; in[0][2] = cx;
    in[1][1] = fy; in[1][2] = cy;
    in[2][2] = 1;

    OPENCV_CALL( cvCalcImageHomography(line, &center, in, h) );
    
    rez_h = 0;
    for(i=0;i<3;i++)
    {
        fscanf( fil_ver, "%f %f %f\n", &hv[0], &hv[1], &hv[2]);
        for(j=0;j<3;j++)
        {
            rez_h+=(hv[j] - h[i][j])*(hv[j] - h[i][j]);
        }
    }
    rez+=sqrt(rez_h)/9.;

/*   image unwarping         */
    size.width = image->width; 
    size.height = image->height; 
    OPENCV_CALL( imagew = cvCreateImage(size, IPL_DEPTH_8U,3) );
    OPENCV_CALL( image_maskw = cvCreateImage(size, IPL_DEPTH_8U,1) );

    iplSet(image_maskw, 0);

    cvSetImageROI(image, hand_roi);
    cvSetImageROI(image_mask, hand_roi);

/* convert homographic transformation matrix from float to double      */
    for(i=0;i<3;i++)
        for(j=0;j<3;j++)
            coeffs[i][j] = (double)h[i][j];

/*  get bounding rectangle for image ROI         */
    iplGetPerspectiveBound(image, coeffs, rect);

    width = (int)(rect[1][0] - rect[0][0]);
    height = (int)(rect[1][1] - rect[0][1]);
    hand_roi_trans.x = (int)rect[0][0];hand_roi_trans.y = (int)rect[0][1];
    hand_roi_trans.width = width; hand_roi_trans.height = height;

    cvMaxRect(&hand_roi, &hand_roi_trans, &hand_roi);
    iplSetROI((IplROI*)image->roi, 0, hand_roi.x, hand_roi.y,
               hand_roi.width,hand_roi.height);
    iplSetROI((IplROI*)image_mask->roi, 0, hand_roi.x, hand_roi.y,
                hand_roi.width,hand_roi.height);

    warpFlag = IPL_WARP_R_TO_Q;
/*    interpolate = IPL_INTER_CUBIC;   */
/*    interpolate = IPL_INTER_NN;      */
    interpolate = IPL_INTER_LINEAR;
    iplWarpPerspective(image, imagew, coeffs, warpFlag, interpolate);
    iplWarpPerspective(image_mask, image_maskw, coeffs, warpFlag, IPL_INTER_NN);  
    
/*  set new image and mask ROI after transformation        */
    iplSetROI((IplROI*)imagew->roi,0, (int)rect[0][0], (int)rect[0][1],(int)width,(int)height);
    iplSetROI((IplROI*)image_maskw->roi,0, (int)rect[0][0], (int)rect[0][1],(int)width,(int)height);

/*  copy image ROI to new image and resize        */
    size.width = width; size.height = height;
    image_rez = cvCreateImage(size, IPL_DEPTH_8U,3);
    mask_rez = cvCreateImage(size, IPL_DEPTH_8U,1);
 
    iplCopy(imagew,image_rez);
    iplCopy(image_maskw,mask_rez);
    
/* convert rezult image from RGB to HSV               */
    image_hsv = iplCreateImageHeader(3, 0, IPL_DEPTH_8U, "HSV", "HSV",
                                   IPL_DATA_ORDER_PIXEL, IPL_ORIGIN_TL,IPL_ALIGN_DWORD,
                                   image_rez->width, image_rez->height, NULL, NULL, NULL, NULL);
    iplAllocateImage(image_hsv, 0, 0 ); 
    strcpy(image_rez->colorModel, "RGB");
    strcpy(image_rez->channelSeq, "RGB");
    image_rez->roi = NULL;

    iplRGB2HSV(image_rez, image_hsv);

/* convert to three images planes                      */
    img_p[0] = cvCreateImage(size, IPL_DEPTH_8U,1);
    img_p[1] = cvCreateImage(size, IPL_DEPTH_8U,1);
    img_v = cvCreateImage(size, IPL_DEPTH_8U,1);

    cvCvtPixToPlane(image_hsv, img_p[0], img_p[1], img_v, NULL);
   
/*  calculate histograms                */
    hist = cvCreateHist ( 2, hdim, CV_HIST_ARRAY);
    hist_mask = cvCreateHist ( 2, hdim, CV_HIST_ARRAY);

/*  install histogram threshold         */
    thresh[0] = (float*) trsmAlloc(2*sizeof(float));
    thresh[1] = (float*) trsmAlloc(2*sizeof(float));

    thresh[0][0] = thresh[1][0] = -0.5;
    thresh[0][1] = thresh[1][1] = 255.5;
    cvSetHistThresh( hist, thresh, 1);
    cvSetHistThresh( hist_mask, thresh, 1);

    cvCalcHist(img_p, hist, 0);
        
    cvCalcHistMask(img_p, mask_rez, hist_mask, 0);
            
    cvCalcProbDensity(hist, hist_mask, hist_mask);

    cvCalcBackProject( img_p, mask_rez, hist_mask ); 

/*  read verify final image mask                  */
    final_mask_ver = atsCreateImageFromFile( name_final_mask_very );
    if(final_mask_ver == NULL)   {code = TRS_FAIL; goto m_exit;}

    rez+= iplNorm(final_mask_ver, mask_rez, IPL_L2) / (width*height+0.);

    trsWrite( ATS_CON | ATS_SUM, "\n gesture recognition \n");
    trsWrite( ATS_CON | ATS_SUM, "result testing error = %f \n",rez);

    if(rez > eps_rez) code = TRS_FAIL;
    else code = TRS_OK;
    
m_exit:    

    cvReleaseImage(&image_mask);
    cvReleaseImage(&mask_rez);
    cvReleaseImage(&image_rez);
    atsReleaseImage(final_mask_ver);
    atsReleaseImage(init_mask_ver);

    cvReleaseImage(&imagew);
    cvReleaseImage(&image_maskw); 

    cvReleaseImage(&img_p[0]);
    cvReleaseImage(&img_p[1]);
    cvReleaseImage(&img_v);
 
    cvReleaseHist( &hist);
    cvReleaseHist( &hist_mask);
    
    cvReleaseMemStorage ( &storage );

    trsFree(pp);
    trsFree(name_final_mask_very);
    trsFree(name_init_mask_very);
    trsFree(name_image);
    trsFree(name_range_image);
    trsFree(name_verify_data);

    fclose(filin);
    fclose(fil_ver);

    
/*    _getch();       */
    return code;
}




void InitAGestureRecognition()
{
/* Test Registaration */
    atsGetTestDataPath( data_path, "GestureRecognition", 0, 0 );
        
    trsReg(cFuncName[0],cTestName,cTestClass,aGestureRecognition); 

} /*InitAGestureRecognition*/

/* End of file. */

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕不卡一区| 国产精品欧美极品| 欧美日本一区二区三区| 色欧美片视频在线观看| 一本一道综合狠狠老| 成人aa视频在线观看| 国产传媒一区在线| 99这里只有精品| 欧美另类高清zo欧美| 久久亚洲精品小早川怜子| 欧美精品一区二区三| 97久久精品人人澡人人爽| 亚洲一二三区在线观看| 经典三级在线一区| av不卡一区二区三区| 3d动漫精品啪啪1区2区免费| 精品国产免费久久| 亚洲自拍另类综合| 成人性生交大片免费看视频在线| 91麻豆自制传媒国产之光| 欧美一区二区三区影视| 国产欧美一区二区三区沐欲 | 久久这里只有精品视频网| 国产精品久久久久婷婷二区次| 天堂一区二区在线免费观看| 国产v综合v亚洲欧| 久久久久久久久一| 首页综合国产亚洲丝袜| 99视频精品免费视频| 精品国产自在久精品国产| 亚洲一级在线观看| 色综合久久久久| 亚洲特黄一级片| 成人性色生活片| 亚洲国产高清aⅴ视频| 精品亚洲国产成人av制服丝袜| 欧美麻豆精品久久久久久| 亚洲视频在线观看一区| 不卡高清视频专区| 欧美国产精品一区二区三区| 国产精品一区二区你懂的| 精品国产乱码久久久久久夜甘婷婷| 亚洲制服欧美中文字幕中文字幕| 91亚洲永久精品| 日韩一区在线免费观看| 色哟哟国产精品免费观看| 亚洲欧美国产77777| 色狠狠色噜噜噜综合网| 亚洲一区二区视频| 欧美一级日韩免费不卡| 久久精品国产精品亚洲红杏| 久久久亚洲综合| 99久久夜色精品国产网站| 亚洲天堂福利av| 欧美一区二区大片| 国产成人精品三级麻豆| 亚洲欧美电影一区二区| 制服视频三区第一页精品| 久国产精品韩国三级视频| 中文字幕免费不卡| 欧美亚洲图片小说| 蜜桃视频在线一区| 亚洲欧洲一区二区三区| 欧美老年两性高潮| 成人免费黄色大片| 天天综合网天天综合色| 中文字幕日本不卡| 精品成人一区二区| 欧美性高清videossexo| 麻豆极品一区二区三区| 亚洲一区二区三区中文字幕在线| 精品国精品自拍自在线| 欧美日产在线观看| 成人免费高清视频| 五月天婷婷综合| 亚洲精品免费在线观看| 国产欧美一区二区三区沐欲| 91精品国产综合久久精品| 欧洲日韩一区二区三区| 97久久精品人人澡人人爽| 成人精品一区二区三区四区| 国产一区三区三区| 青青国产91久久久久久| 日本欧美一区二区三区乱码| 亚洲国产一区二区在线播放| 亚洲综合999| 亚洲第一福利一区| 亚洲午夜国产一区99re久久| 亚洲另类色综合网站| 亚洲精品乱码久久久久久| 亚洲免费色视频| 五月天国产精品| 蜜臀91精品一区二区三区| 久久99精品久久久久久国产越南 | 久久一区二区视频| 精品国产1区2区3区| 久久精品男人的天堂| 18成人在线观看| 日韩成人免费在线| 国产精品18久久久久久vr| 国产精品原创巨作av| 91网站视频在线观看| 91麻豆精品国产91| 久久久久久久久久久99999| 国产精品视频麻豆| 亚洲国产精品精华液2区45| 亚洲精选视频在线| 久久9热精品视频| 99久久精品免费看| 日韩女优电影在线观看| ...av二区三区久久精品| 香蕉成人伊视频在线观看| 国产麻豆精品在线观看| 欧美欧美午夜aⅴ在线观看| 久久九九久久九九| 日韩电影在线观看网站| 99re热视频这里只精品| 久久精品亚洲精品国产欧美kt∨| 亚洲免费视频中文字幕| 成人深夜视频在线观看| 欧美大片一区二区三区| 日本中文字幕不卡| 欧美偷拍一区二区| 夜夜亚洲天天久久| 日本丰满少妇一区二区三区| 日本一区二区免费在线观看视频| 麻豆精品一区二区av白丝在线| 欧美亚洲禁片免费| 午夜视频久久久久久| 91精彩视频在线| 亚洲风情在线资源站| 91精品办公室少妇高潮对白| 亚洲免费观看高清| 91官网在线免费观看| 亚洲中国最大av网站| 欧美日韩一区二区电影| 日韩激情视频在线观看| 制服丝袜亚洲精品中文字幕| 另类小说一区二区三区| 久久香蕉国产线看观看99| 国产东北露脸精品视频| 国产精品久久毛片a| 在线亚洲一区二区| 麻豆国产欧美一区二区三区| 欧美国产精品v| 欧美精品丝袜中出| 国产寡妇亲子伦一区二区| 亚洲青青青在线视频| 69堂亚洲精品首页| 岛国av在线一区| 首页亚洲欧美制服丝腿| 国产欧美一区二区三区在线看蜜臀| 91在线精品一区二区| 日韩av午夜在线观看| 国产精品麻豆一区二区| 911精品国产一区二区在线| 国产精品自在欧美一区| 亚洲国产欧美在线人成| 国产偷国产偷精品高清尤物 | 久久伊人蜜桃av一区二区| 一本到高清视频免费精品| 美腿丝袜亚洲一区| 亚洲精品国产无天堂网2021| 成人黄色在线看| 久久久久久一二三区| 日本视频在线一区| 91精品国产免费| 欧美影院精品一区| 丁香亚洲综合激情啪啪综合| 免费精品视频最新在线| 亚洲精品中文在线观看| 国产精品狼人久久影院观看方式| 91麻豆精品国产| 宅男在线国产精品| 欧美色综合天天久久综合精品| 97久久超碰国产精品| 不卡一区在线观看| 91蜜桃传媒精品久久久一区二区| 粉嫩嫩av羞羞动漫久久久| 国产精品中文字幕日韩精品| 精品无人区卡一卡二卡三乱码免费卡| 亚洲午夜久久久久久久久久久 | 老司机精品视频一区二区三区| 亚洲国产成人av网| 日韩激情一区二区| 久久成人免费日本黄色| 黄色小说综合网站| 91小视频在线免费看| 欧美午夜精品理论片a级按摩| 欧美日韩黄色影视| 国产欧美在线观看一区| 亚洲天堂精品视频| 婷婷开心久久网| 粉嫩欧美一区二区三区高清影视| 91激情五月电影| 制服.丝袜.亚洲.另类.中文| 国产午夜亚洲精品羞羞网站| 中文字幕一区二区在线播放| 日韩电影免费在线| 色综合久久中文综合久久97|