Ask Your Question
0

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

asked 2015-05-28 08:39:01 -0600

Akki gravatar image

updated 2015-05-28 09:08:25 -0600

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.

edit retag flag offensive close merge delete

Comments

1

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

berak gravatar imageberak ( 2015-05-28 09:06:43 -0600 )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 ( 2015-05-29 04:47:12 -0600 )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 ( 2015-05-29 04:58:33 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-05-28 09:03:23 -0600

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.

edit flag offensive delete link more

Comments

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

Akki gravatar imageAkki ( 2015-05-29 04:26:45 -0600 )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 ( 2015-05-29 04:46:15 -0600 )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 ( 2015-06-01 04:17:24 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-05-28 08:39:01 -0600

Seen: 1,808 times

Last updated: May 28 '15