zoukankan      html  css  js  c++  java
  • directshow采集图像转换成OPENCV

    #include "stdafx.h" 
    #include 
    <stdio.h> 
    #include 
    <cv.h> 
    #include 
    "cxcore.h" 
    #include 
    <highgui.h> 
    #include 
    "math.h" 
    #include 
    <stdio.h> 
    #include 
    <ctype.h> 
    #include 
    "ARFrameGrabber.h" 
    //#include <streams.h> 

    void main(int argc, char* argv[]) 

    IplImage 
    *frame =0
    static ARFrameGrabber frameGrabber; //声明对象 
    IplImage ds_frame; 
    frameGrabber.Init(
    0true); //设置支持directshow的设备编号,从0开始 
    frameGrabber.SetFlippedImage(true); //图像是否翻转 
    for(;;) 

    frameGrabber.GrabByteFrame(); 
    //获取一帧 
    BYTE *myBuffer = frameGrabber.GetByteBuffer(); //得到图像的缓冲 
    int width = frameGrabber.GetWidth(); 
    int height = frameGrabber.GetHeight(); 
    int stride = (width * sizeof( RGBTRIPLE ) + 3& -4
    cvInitImageHeader( 
    &ds_frame, cvSize(width, height), 83,IPL_ORIGIN_BL, 4 ); //创建iplimage 
    ds_frame.widthStep = stride; 
    cvSetData( 
    &ds_frame, myBuffer, stride ); //copy数据 
    frame = &ds_frame; 

    /* 视频分析部分 */ 
    //int nFrmNum = 0; 
    cvNamedWindow("vedio",1); 
    cvShowImage(
    "vedio",frame); 
    if (cvWaitKey(20)>=0
    break

    }
     
    cvReleaseImage(
    &frame); 
    cvDestroyWindow(
    "vedio"); 
    }
  • 相关阅读:
    屏幕适配的发展历史
    NSURLConnection / NSURLSession/ SDWebImage
    版本工具管理之----git
    Framework、Cocoa、Xcode
    UICollectionView-网格视图
    博客园每日一卦o(* ̄︶ ̄*)o
    平凡的程序猿
    如何使用java代码启动tomcat和打开浏览器
    web项目部署以及放到ROOT目录下
    java项目打包生成MD5文件
  • 原文地址:https://www.cnblogs.com/wqj1212/p/1052726.html
Copyright © 2011-2022 走看看