0

RGBビデオをグレースケールに変換しようとしているopencvは初めてですが、常にエラーエラーLNK2019が発生します:関数_wmainで参照されている未解決の外部シンボル_cvCvtColor私が間違っていることを教えてください

#include "stdafx.h"
#include "highgui.h"
#include <stdio.h>
#include <cv.h>
#include <tchar.h>
#include <highgui.h>
#include <stdio.h>
#include <conio.h>
#include <opencv2/imgproc/imgproc.hpp>  // Gaussian Blur
#include <opencv2/core/core.hpp>        // Basic OpenCV structures (cv::Mat, Scalar)
#include <opencv2/highgui/highgui.hpp>

#include <iostream>
#include <conio.h>

using namespace cv;
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    CvCapture* capture = 0;
    capture = cvCreateFileCapture( "video.avi" );
    if(!capture)
    {
        return -1;
    }
    IplImage *bgr_frame=cvQueryFrame(capture);//Init the video read
    double fps = cvGetCaptureProperty (capture,CV_CAP_PROP_FPS);

    CvSize size = cvSize((int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH),(int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT));
    CvVideoWriter *writer = cvCreateVideoWriter("izlaz.avi",CV_FOURCC_DEFAULT,fps,size);

    IplImage *grayScaleImage = cvCreateImage(size ,IPL_DEPTH_8U,1);

    while( (bgr_frame=cvQueryFrame(capture)) != NULL )
    {
        cvCvtColor(bgr_frame, grayScaleImage, CV_BGR2GRAY);
        cvWriteFrame( writer, grayScaleImage );
    }

    cvReleaseVideoWriter( &writer );
    cvReleaseCapture( &capture );
}
4

3 に答える 3

1

ライブラリ imgproc を追加しました。私はopencv 2.3を使用しています。このプレスの場合

ALT+F7 構成プロパティ -> 入力 -> 追加の依存関係 -> この opencv_imgproc230.lib を編集してコピーします

于 2013-09-15T12:03:22.473 に答える
0

この更新を試してください

#含む

#include <opencv2\highgui\highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include <iostream>


int main (){

cv::Mat frame;
cv::VideoCapture cap("Grabbed video.avi");//("Wildlife.wmv");
int key =0;
cap>>frame;
cv::VideoWriter record("Grabbed2 video.avi",CV_FOURCC('M','J','P','G'), 30,frame.size(), 0);
while(key != 27){
    if(cap.isOpened()){
    cap >>frame;
    if(!frame.empty()){
        cv::cvtColor(frame,frame,CV_BGR2GRAY);
        record<<frame;
        imshow("fvakjb",frame);
    }
    }

    else key =27;
    //cv::cvtColor(frame,frame,CV_BGR2GRAY);




key= cv::waitKey(10);
}
record.release();
cap.release();
return 0;

}

于 2013-09-13T14:13:04.950 に答える