gpt4 book ai didi

OpenCV 窗口无法加载

转载 作者:太空宇宙 更新时间:2023-11-03 20:59:34 25 4
gpt4 key购买 nike

我正在做指纹匹配的项目,我是 openCV 库的新手,

这是一个显示直方图的简单代码,存在于openCV的示例文件夹中

int main(int, char** argv)
{
Mat src, dst;

/// Load image


src = cv::imread("‪contour.jpg");
cv::waitKey(5000);
//waitKey(0);
if (!src.data)
{

return -1;
}

/// Separate the image in 3 places ( B, G and R )
..
vector<Mat> bgr_planes;
split(src, bgr_planes);

/// Establish the number of bins
int histSize = 256;

/// Set the ranges ( for B,G,R) )
float range[] = { 0, 256 };
const float* histRange = { range };

bool uniform = true; bool accumulate = false;

Mat b_hist, g_hist, r_hist;

/// Compute the histograms:
calcHist(&bgr_planes[0], 1, 0, Mat(), b_hist, 1, &histSize, &histRange, uniform, accumulate);
calcHist(&bgr_planes[1], 1, 0, Mat(), g_hist, 1, &histSize, &histRange, uniform, accumulate);
calcHist(&bgr_planes[2], 1, 0, Mat(), r_hist, 1, &histSize, &histRange, uniform, accumulate);

// Draw the histograms for B, G and R
int hist_w = 512; int hist_h = 400;
int bin_w = cvRound((double)hist_w / histSize);

Mat histImage(hist_h, hist_w, CV_8UC3, Scalar(0, 0, 0));

/// Normalize the result to [ 0, histImage.rows ]
normalize(b_hist, b_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat());
normalize(g_hist, g_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat());
normalize(r_hist, r_hist, 0, histImage.rows, NORM_MINMAX, -1, Mat());

/// Draw for each channel
for (int i = 1; i < histSize; i++)
{
line(histImage, Point(bin_w*(i - 1), hist_h - cvRound(b_hist.at<float>(i - 1))),
Point(bin_w*(i), hist_h - cvRound(b_hist.at<float>(i))),
Scalar(255, 0, 0), 2, 8, 0);
line(histImage, Point(bin_w*(i - 1), hist_h - cvRound(g_hist.at<float>(i - 1))),
Point(bin_w*(i), hist_h - cvRound(g_hist.at<float>(i))),
Scalar(0, 255, 0), 2, 8, 0);
line(histImage, Point(bin_w*(i - 1), hist_h - cvRound(r_hist.at<float>(i - 1))),
Point(bin_w*(i), hist_h - cvRound(r_hist.at<float>(i))),
Scalar(0, 0, 255), 2, 8, 0);
}

/// Display
namedWindow("calcHist Demo", WINDOW_AUTOSIZE);

imshow("calcHist Demo", histImage);

waitKey(0);

return 0;

}

我将文件 contour.jpg 保存在与 cpp 文件相同的文件夹中。

我尝试了很多,但它显示以下警告并且不显示输出窗口。

我也尝试更改命令参数变量,仍然没有输出。

'ConsoleApplication5.exe' (Win32): Loaded 'C:\Users\jaythegenius48\Documents\Visual Studio 2013\Projects\ConsoleApplication5\Debug\ConsoleApplication5.exe'. Symbols loaded.
'ConsoleApplication5.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Symbols loaded.
'ConsoleApplication5.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Symbols loaded.
'ConsoleApplication5.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Symbols loaded.
'ConsoleApplication5.exe' (Win32): Loaded 'C:\opencv\build\x86\vc12\bin\opencv_core249.dll'. Cannot find or open the PDB file.
'ConsoleApplication5.exe' (Win32): Loaded 'C:\opencv\build\x86\vc12\bin\opencv_highgui249.dll'. Cannot find or open the PDB file.
'ConsoleApplication5.exe' (Win32): Loaded 'C:\opencv\build\x86\vc12\bin\opencv_imgproc249.dll'. Cannot find or open the PDB file.
'ConsoleApplication5.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp120d.dll'. Symbols loaded.

The program '[916] ConsoleApplication5.exe' has exited with code -1 (0xffffffff).

感谢您的帮助,谢谢

编辑:好的,这是我自己的问题的解决方案:

1) 我不知道自己做了什么,但我开始了一个新项目。

2) 右键单击​​您的项目,然后单击 -> 属性。

3) 取决于您的 opencv 目录(我建议 Windows 使用“C:\opencv”)

在include目录和library目录中做如下改动(选择相应的

文件夹)。我建议使用 x86 文件夹,即使你有 64 位架构。

Screenshot

4) 然后是以下三张图片:C/C++

Linker General

最后: Edit in Additional Dependancy

在该文本空白区域添加以下文件。

注意:根据你的 opencv 版本文件名会改变,我的是 2.4.9 所以它以 249 结尾,对于那些使用 2.4.3 的人来说是 243 。

opencv_calib3d249d.lib    
opencv_contrib249d.lib
opencv_core249d.lib
opencv_features2d249d.lib
opencv_flann249d.lib
opencv_gpu249d.lib
opencv_highgui249d.lib
opencv_imgproc249d.lib
opencv_legacy249d.lib
opencv_ml249d.lib
opencv_nonfree249d.lib
opencv_objdetect249d.lib
opencv_photo249d.lib
opencv_stitching249d.lib
opencv_ts249d.lib
opencv_video249d.lib
opencv_videostab249d.lib

我希望这会有所帮助。虽然令人沮丧,但努力工作会有返回。

感谢其他成员回答我的问题。

最佳答案

处理文件(在我看来)是一件比较难做的事情。也就是说,将它们放在哪里。

尝试将图像放在与可执行文件 相同的目录中,而不是源文件中。

关于OpenCV 窗口无法加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23171414/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com