First time here? Check out the FAQ!

Ask Your Question
0

error C2664: 'cv::imread' : cannot convert parameter 1 from 'wchar_t *' to 'const std::string &'

asked May 28 '15

Akki gravatar image

updated May 28 '15

berak gravatar image

hello,

I am getting error as state above. here he the fraction of the code, in header file there is class:

 class projectresults
{
public:
    std::wstring TubeType;
    double VolumeHeightMM;
};

class project
{
public:
     project(void);
    ~project(void);


    projectresults process(std::list<projectparameter>& ParameterSet, wchar_t *imgName);

    double contour();   
    double plazmaH, Y02;

};

in .cpp file there is defination

projectresults project::process(std::list<projectparameter>& ParameterSet, /*char* imgName*/  wchar_t *imgName)
 {
    Mat imgOriginal =imread(**imgName**, 1);

please guide me how can I solve this error.

Thank you very much in advance.

Preview: (hide)

Comments

1

do you have to use wchar_t* ? (there is indeed no conversion)

berak gravatar imageberak (May 28 '15)edit

wchar_t *imgName is pointer for image data and i Have to do operation like edge detection or something like this, so its possible to do so without imread or Mat function. i.e. I am not getting direct image to do process.

Akki gravatar imageAkki (May 29 '15)edit
1

"wchar_t imgName is pointer for image data" - what ? your code is telling a different story, it's the *filename, not the image (pixel) data.

please, before writing any further code based on speculation, rather try some of the tutorials

berak gravatar imageberak (May 29 '15)edit

1 answer

Sort by » oldest newest most voted
2

answered May 28 '15

pklab gravatar image

You can't use wchar_t* as filename in imread.

Read documentation for imread:

C++: Mat imread(const string& filename, int flags=1 )

where filename must be a std::string or char* or "a file name".

Your question should be How to convert wchar to std::string that is out of scope.

Preview: (hide)

Comments

Thank you for comment.It means its is not possible to use wchar_t*.

Akki gravatar imageAkki (May 29 '15)edit

wchar_t *imgName is pointer for image data and i Have to do operation like edge detection or something like this, so its possible to do so without imread or Mat function. i.e. I am not getting direct image to do process.

Akki gravatar imageAkki (May 29 '15)edit

I don't clear undestant ... imread is used to read an image from file (.jpg, .bmp, .tif etc...) into a Mat object. File name must be as above. All operation on image are done on a Mat object. So...your function can be projectresults process(std::list<projectparameter>& ParameterSet, char* imgName); than imread can works.

pklab gravatar imagepklab (Jun 1 '15)edit

Question Tools

1 follower

Stats

Asked: May 28 '15

Seen: 1,981 times

Last updated: May 28 '15