OpenCV window cannot load

I'm working on a project for fingerprint matching, and I'm new to using the openCV library,

This is a simple code when displaying a histogram, which is present in the openCV sample folder

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;

    }

I saved the contour.jpg file in the same folder as the cpp file.

I tried a lot, but it shows the following warning and the output window does not appear.

I also tried changing the variable of the command argument, still not outputting.

'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).

Your help will be appreciated, thanks

EDIT: Well, here's a solution to my own question:

1) I do not know what I did, but I started with a new project.

2) Right-click your project, and then → Properties.

3) Depending on your opencv directory (I suggest "C: \ opencv" for windows),

include (

). x86, 64- .

Screen shot

4) : C / c ++

Linker general

: Edit in Additional Dependancy

.

. opensv , 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    

, . , .

.

+4
1

- ( ) . , .

, , .

+2

Source: https://habr.com/ru/post/1537203/


All Articles