So i'm trying to make opencv open a image i have saved on my computer and display it in a window. But my visual studio compiler keeps throwing this excpetion:
Exception thrown at 0x00007FF80A2012DB (vcruntime140.dll) in Pixel_analisys.exe: 0xC0000005: Access violation reading location 0x0000021037BD4000.
I have tried to change the file location, double checked the linker if the libraries was linked.
However using the cv:haveImageReader()
with the same file path it says it is not accesable/not permissions to access it, i have double checked the file location and checked if it is locked in any way and still cant figure this out.
#include <windows.h>
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
using namespace std;
cv::Mat a;
int main()
{
a = cv::imread("C:\\Users\\simuls26\\Desktop\\dog.jpg");
cv::imshow("dog", a);
return 0;
}
This is my callstack:
vcruntime140.dll!memcpy_repmovs() Line 40 Unknown [Inline Frame] msvcp140.dll!std::_Char_traits<char,int>::copy(char * const) Line 64 C++ msvcp140.dll!std::basic_streambuf<char,std::char_traits>::xsputn(const char * _Ptr, __int64 _Count) Line 345 C++ opencv_world455.dll!std::_Insert_string<char,struct std::char_traits,unsigned __int64>(class std::basic_ostream<char,struct std::char_traits > &,char const * const,unsigned __int64) C++ opencv_world455.dll!std::allocator<struct cv::Ptr >::deallocate(struct cv::Ptr * const,unsigned __int64) C++ opencv_world455.dll!cv::imread(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,int) C++ opencv_world455.dll!cv::imread(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,int) C++ Pixel_analisys.exe!main() Line 14 C++ [External Code]
EDIT: I have fixed the .dll compiler issue by using the visual studio 2015 toolset instead of the 2022 toolset. However now my program wont open my picture. My code is still the same and i have trippled checked my file path. the console output i'm getting are as following
[ WARN:[email protected]] global C:\build\master_winpack-build-win64-vc15\opencv\modules\imgcodecs\src\loadsave.cpp (239) cv::findDecoder imread_('
failed to open img.jpg
cv::imread
related or not. If you have not, be sure that there's no compiler version mismatch with the static and dynamic libraries. - Orkhan Aliyev