Heim > Fragen und Antworten > Hauptteil
在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中文网2017-04-17 13:21:08
请正确配置,见图
图1:包含目录是指你#include的文件所处的目录。库目录是指所有lib文件所处的目录。
你的dll无法定位的问题,应该是下图没有配置好。
图2:链接器-输入是指所有dll所在的目录,注意这个配置的release和debug需要的dll是不一样的,区别在版本249后有没有d这个字母。