简体   繁体   中英

Correct path to read an image in Opencv(c++)?

I wrote bellow code to read and show an image from a path in widows:

#include "SIFT.h"
#include <Windows.h>
#include <opencv2/opencv.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/core/core.hpp>

int main(int argc, const char* argv[])
{

    cv::Mat input = cv::imread("F:/Personal/1.jpg", IMREAD_COLOR);
     if (input.empty()){
         cout << "is empty";
         getchar();
         return -1;

     }
     namedWindow("Display window", WINDOW_AUTOSIZE);// Create a window for display.
     imshow("Display window", input);
    cv::waitKey(0);
    //cv::Mat* m = &input; 
    //implementSIFT s(input, nullptr, nullptr, nullptr);
    return 0;
}

But the image seems empty. What is correct path to read an image? Or Where is the problem from?

正确的路径应为:

    cv::Mat input = cv::imread("F:\\Personal/1.jpg", IMREAD_COLOR);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM