c++opencvimread

Opencv imread does not work with relative path


As the title says. I've tried to load an image with argv and with absolute path and it worked, but with relative path it doesn't. The image is in the same directory of the executable. I'm using visual studio 2013 and opencv 2.4.10 on windows 7 64 bit. How can I resolve?

EDIT

Here's my code:

include <iostream>
#include <fstream>
#include "opencv2\highgui\highgui.hpp"
#include "opencv2\stitching\stitcher.hpp"
#include "opencv2\core\core.hpp"


using namespace cv;
using namespace std;


void main()
{
    vector< Mat > vImg;
    Mat rImg;

    vImg.push_back(imread("1.png"));
    vImg.push_back(imread("2.png"));
    vImg.push_back(imread("3.png"));


    Stitcher stitcher = Stitcher::createDefault(true);


    unsigned long AAtime = 0, BBtime = 0; //check processing time  
    AAtime = getTickCount(); //check processing time  

    stitcher.stitch(vImg, rImg);

    BBtime = getTickCount(); //check processing time   
    printf("%.2lf sec \n", (BBtime - AAtime)
    getTickFrequency());         //check processing time  

    namedWindow("Stitching Result");
    imshow("Stitching Result", rImg);

    waitKey(0);

}

I tried also to use "./" "/" "//" "\" and "\",but it still not working!


Solution

  • As CTZStef said, the images must not be in the sln folder but in the folder with the VC++ project file!