c++ - VS2013环境下被OpenCV这个鬼畜的问题折磨好几天了
PHP中文网
PHP中文网 2017-04-17 13:19:08
0
1
610

在Mastering OpenCV with Practical CV Project书中的第一章 将图片变成素描的示例中,我尝试以下代码,OpenCV配置是没有问题的,因为我用一个demo示例将图片显示了出来,可下面这段代码始终运行不成功。opencv_imgproc249d.dll,opencv_highgui249d.dll,opencv_core249d.dll,cannot find or open PDB file,已经把百度上有关这个问题的前5页全部看了一遍,依旧没有解决...
下面是

/*main_desktop.cpp*/
#include "stdafx.h"
#include <stdlib.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <highgui.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <fstream>
#include <iostream>
#include "cartoon.h"

using namespace std;
using namespace cv;

int main(int argc, char* argv[])
{
    int camerNumber = 1;
    if (argc > 1){
        camerNumber = atoi(argv[1]);
        
    }
    cout<<"how are you"<<endl;
    //get access to the camera


    /*打开摄像头+绘图*/

    //声明IplImage指针
    IplImage* pFrame;
    //IplImage* displayedFrame=NULL;
    //获取摄像头
    CvCapture* pCapture = cvCreateCameraCapture(0);
    
    //创建窗口
    cvNamedWindow("NiuBility", CV_WINDOW_AUTOSIZE);
    if (!pCapture)
        cout << "Fuck" << endl;

    while (true){
        Mat cameraFrame;
        cameraFrame = cvQueryFrame(pCapture);
        Mat displayedFrame = Mat(cameraFrame.size(), CV_8UC3);
        //displayedFrame = cameraFrame;将这句注释取消掉,可以成功调用摄像头,并显示

        cartoonifyImage(cameraFrame, displayedFrame);//即使将cart…Image函数改成displayedFram=cameraFrame,摄像头显示不出来了。

        imshow("Niubility", displayedFrame);
        char c = cvWaitKey(3);
        if (c == 27)break;
    }
    cvReleaseCapture(&pCapture);
    cvDestroyWindow("Niubility");

    return 0;
}
/*cartoon.cpp*/
#include "stdafx.h"
#include "opencv2/opencv.hpp"
#include "cartoon.h"

using namespace cv;
using namespace std;


//void cartoonifyImage(IplImage* srcColor_img , IplImage* result_img){
void cartoonifyImage(Mat srcColor_img, Mat result_img){
    
    /*测试该函数*/
    result_img = srcColor_img;


    //cout << "how are you" << endl;
    ////IplImage转为Mat
    //Mat srcColor = srcColor_img;
    ////均值滤波器
    //Mat gray;
    //cvtColor(srcColor, gray, CV_BGR2GRAY);
    //const int MEDIAN_BLUR_FILTER_SIZE = 7;
    //medianBlur(gray, gray, MEDIAN_BLUR_FILTER_SIZE);
    //
    ////拉普拉斯滤波器
    //Mat edges;
    //const int LAPLACIAN_FILTER_SIZE = 5;
    //Laplacian(gray, edges, CV_8U, LAPLACIAN_FILTER_SIZE);
    ////阈值反转处理
    //Mat mask;
    //const int EDGES_THRESHOLD = 80;
    //threshold(edges, mask, EDGES_THRESHOLD, 255, THRESH_BINARY_INV);
    //
    //result_img = mask;
    
}
/*cartoon.h*/
using namespace cv;

void cartoonifyImage(Mat a, Mat b);
//void cartoonifyImage(IplImage* a, IplImage* b);
PHP中文网
PHP中文网

认证0级讲师

reply all(1)
Ty80

Please configure it correctly, see picture


Figure 1: Include directory refers to the directory where the file you #include is located. Library directory refers to the directory where all lib files are located.

The problem that your dll cannot be located may be that the following picture is not configured properly.

Figure 2: Linker-Input refers to the directory where all dlls are located. Note that the dlls required for release and debug of this configuration are different. , the difference lies in whether there is the letter d after version 249.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template