无法使OpenCV应用程序在x64中工作

时间:2018-07-29 19:14:05

标签: c++ opencv

试图使此代码在x64中编译。我在x86中成功编译了它。但是在x64中,我得到了:

1>------ Build started: Project: ConsoleApplication4, Configuration: Release x64 ------
1> stdafx.cpp
1> ConsoleApplication4.cpp
1>ConsoleApplication4.cpp(21): warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
1>ConsoleApplication4.cpp(22): warning C4244: 'initializing' : conversion from 'double' to 'int', possible loss of data
1>ConsoleApplication4.obj : error LNK2001: unresolved external symbol "private: char * __cdecl cv::String::allocate(unsigned __int64)" (?allocate@String@cv@@AEAAPEAD_K@Z)
1>ConsoleApplication4.obj : error LNK2001: unresolved external symbol "private: void __cdecl cv::String::deallocate(void)" (?deallocate@String@cv@@AEAAXXZ)
1>ConsoleApplication4.obj : error LNK2001: unresolved external symbol "public: virtual double __cdecl cv::VideoCapture::get(int)const " (?get@VideoCapture@cv@@UEBANH@Z)
1>ConsoleApplication4.obj : error LNK2001: unresolved external symbol "public: __cdecl cv::VideoWriter::VideoWriter(class cv::String const &,int,double,class cv::Size_<int>,bool)" (??0VideoWriter@cv@@QEAA@AEBVString@1@HNV?$Size_@H@1@_N@Z)
1>c:\users\vartotojas\documents\visual studio 2013\Projects\ConsoleApplication4\x64\Release\ConsoleApplication4.exe : fatal error LNK1120: 4 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

其他依赖项:

opencv_core2411.lib
opencv_imgproc2411.lib
opencv_highgui2411.lib
opencv_ml2411.lib
opencv_video2411.lib
opencv_features2d2411.lib
opencv_calib3d2411.lib
opencv_objdetect2411.lib
opencv_contrib2411.lib
opencv_legacy2411.lib
opencv_flann2411.lib
libpng.lib
libtiff.lib
zlib.lib
IlmImf.lib
libjasper.lib
libjpeg.lib
comctl32.lib
gdi32.lib
vfw32.lib

OpenCV版本:2.411 Visual Studio 2013

设置: 平台-x64 相对

不要忘记将库从x86更改为x64。

#include "stdafx.h"


#include "opencv2/opencv.hpp"
#include <iostream>

using namespace std;
using namespace cv;

int main() {

    VideoCapture vcap(0);
    if (!vcap.isOpened()) {
        cout << "Error opening video stream or file" << endl;
        return -1;
    }

    int frame_width = vcap.get(CV_CAP_PROP_FRAME_WIDTH);
    int frame_height = vcap.get(CV_CAP_PROP_FRAME_HEIGHT);
    VideoWriter video("out.avi", CV_FOURCC('M', 'J', 'P', 'G'), 10, Size(frame_width, frame_height), true);

    for (;;) {

        Mat frame;
        vcap >> frame;
        video.write(frame);
        imshow("Frame", frame);
        char c = (char)waitKey(33);
        if (c == 27) break;
    }
    return 0;
}

可以重复,但我没有找到答案。

0 个答案:

没有答案