Having trouble getting OPEN CV 4.12 working on VS22

Hello,

I was able to get OPENCV to make an image and save it, but loading an image always says:

[ WARN:0@0.060] global loadsave.cpp:275 cv::findDecoder imread_(‘’): can’t open/read file: check file path/integrity
OpenCV failed to load image

I tried .jpg, .bmp, .png Nothing loads…

My code:

std::string path = “C:\\openCvProject1\\openCvProject1\\ms_test.png”;

cv::Mat img = cv::imread(path, cv::IMREAD_COLOR); // Load as color image

if (img.empty()) {
std::cout << "Failed to load image at: " << path << std::endl;
return -1;
}

std::cout << "Image loaded successfully: " << img.cols << “x” << img.rows << std::endl;

cv::imshow(“Loaded Image”, img);
cv::waitKey(0);

return 0;

If anyone can help, that’d be great, I’m making an tracker for a robot that should be easy, one big color to look for.

this happens sometimes. if I remember correctly, it is a mismatch between the build mode (debug/release) of your own code and the build mode (debug/release) of OpenCV.

the official package contains release builds. it might also contain debug builds but I’m not sure.

make sure you build your own code in release mode. make sure linking is done against the release builds. both have to match. if you link against the debug build, build your own code in debug mode too.

Crackwitz,

Thank you to the point if you find me financially successful and can track me back here with a reply to prove it’s you, I’ll drop you $.

I’m going to attempt to build a debug version and if it doesn’t work, a release version.

If I couldn’t get OPEN CV working, I was gonna roll my own masks, I’ve done this as a researcher, but I’d rather be a part of the community of OPENCV.

,Jim

Wow wow,

Looked like it worked when I linked only the debug library and not the release.
I’ll do all my work in debug. I might even release on debug. But if I wanted I could compile release someday if I needed it.

Great work crackwitz, that was it!

I’m now a part of the OpenCv community, heheheheheh, sorry :wink:

,GoodNewsJim

Crackwitz,

I was already able to determine EXACTLY where a ball was located in a scene!
Coded in 12 minutes!!! WOWOW!

OpenAi/Grok/Gemini are great for tech stuff.

Now I’m going to make a robot using this tech… Keep ya posted.

,Jim