OpenCV/Patch to enable capturing frame rate setting on OpenCV 2.2

#multilang(ja){{

概要

OpenCV 2.2のDirectShow?によるキャプチャでフレームレート変更を有効にするパッチです.
こちらで配布されているOpenCV-2.2.0-win.zipを対象としたパッチです.

ダウンロード

VersionFilenameSizeDateTypeDownload
1.0highgui_dshow_fps_patch_v1.zip14.96 KB20110702ziphttp://www.atinfinity.info/opencv/extension/highgui_dshow_fps_patch_v1.zip

変更履歴

VersionDate変更内容
1.020110702新規作成

内容物

  • cap_dshow.cpp
    DirectShowによるキャプチャでフレームレート変更を有効にするパッチ
  • precomp.hpp
    OpenCV2.2のバグ修正(※DirectShowのキャプチャ利用に必要)

使い方

  1. 上記リンクからhighgui_dshow_fps_patch_v1.zipをダウンロードして展開します.
  2. 展開したファイル(cap_dshow.cpp、precomp.hpp)を下記ディレクトリにコピーして下さい.
    OpenCV-2.2.0\modules\highgui\src
  3. CMakeでWITH_VIDEOINPUTを有効にしてビルドしてください.

サンプルプログラム

fileenable_fps_setting_dshow.cpp
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"

/* ライブラリのリンク */
#pragma comment( lib, "opencv_core220.lib" )
#pragma comment( lib, "opencv_highgui220.lib" )

int main (int argc, char **argv)
{
    CvCapture *capture = NULL;
    IplImage  *frame   = NULL;
    double w   = 320; /* 幅 */
    double h   = 240; /* 高さ */
    double fps = 30;  /* フレームレート */
    int    c   = 0;

    /* DirectShowを使ったキャプチャ(CV_CAP_DSHOW)初期化 */
    capture = cvCreateCameraCapture(CV_CAP_DSHOW);
    if(capture == NULL)
    {
        fprintf(stderr, "[Error]Could not initialize capturing\n");
        return -1;
    }
    
    /* キャプチャサイズ(縦、横)の指定 */
    cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, w);
    cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, h);

    /* フレームレートの指定 */
    cvSetCaptureProperty(capture, CV_CAP_PROP_FPS, fps);

    cvNamedWindow("Capture", CV_WINDOW_AUTOSIZE);

    while(1)
    {
        frame = cvQueryFrame(capture);
        cvShowImage("Capture", frame);
        c = cvWaitKey(1);
        if(c == '\x1b') break;
    }

    cvReleaseCapture(&capture);
    cvDestroyWindow("Capture");

    return 0;
}

Contact

間違い・御指摘等ありましたら,

mail.png

までメールにてご連絡ください.

}}

#multilang(en){{

Abstract

This page describes the way to enable capturing frame rate setting on OpenCV 2.2.
This patch is intended for OpenCV-2.2.0-win.zip in Official Release.

Download

VersionFilenameSizeDateTypeDownload
1.0highgui_dshow_fps_patch_v1.zip14.96 KB20110702ziphttp://www.atinfinity.info/opencv/extension/highgui_dshow_fps_patch_v1.zip

ChangeLog?

VersionDateChanges
1.020110702First Release

Files

  • cap_dshow.cpp
    This is patch to enable capturing frame rate setting.
  • precomp.hpp
    This is OpenCV 2.2's bug fix patch. It is need to use capturing using DirectShow.

Usage

  1. Please download highgui_dshow_fps_patch_v1.zip. And,extract this file.
  2. Please overwrite the patch's files to the following directory.
    OpenCV-2.2.0\modules\highgui\src
  3. Please enable WITH_VIDEOINPUT on CMake, and build OpenCV.

Sample

fileenable_fps_setting_dshow_en.cpp
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"

/* link library */
#pragma comment( lib, "opencv_core220.lib" )
#pragma comment( lib, "opencv_highgui220.lib" )

int main (int argc, char **argv)
{
    CvCapture *capture = NULL;
    IplImage  *frame   = NULL;
    double w   = 320; /* width of capturing */
    double h   = 240; /* height of capturing */
    double fps = 30;  /* framerate of capturing */
    int    c   = 0;

    /* Initialization of capturing using DirectShow(CV_CAP_DSHOW) */
    capture = cvCreateCameraCapture(CV_CAP_DSHOW);
    if(capture == NULL)
    {
        fprintf(stderr, "[Error]Could not initialize capturing\n");
        return -1;
    }
    
    /* setting size(width, height) of capturing */
    cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, w);
    cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, h);

    /* setting framerate of capturing */
    cvSetCaptureProperty(capture, CV_CAP_PROP_FPS, fps);

    cvNamedWindow("Capture", CV_WINDOW_AUTOSIZE);

    while(1)
    {
        frame = cvQueryFrame(capture);
        cvShowImage("Capture", frame);
        c = cvWaitKey(1);
        if(c == '\x1b') break;
    }

    cvReleaseCapture(&capture);
    cvDestroyWindow("Capture");

    return 0;
}

Contact

If you have question,please send e-mail to the following address.

mail.png

}}


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2011-07-04 (月) 16:54:00 (2303d)