Why after linking the OpenCV libraries, Mat objects are still 'undefined'?
-
wrote on 31 Aug 2023, 07:50 last edited by
-
wrote on 31 Aug 2023, 08:05 last edited by
@Matiyash I read this answer, didn't help :(
https://forum.qt.io/topic/123637/why-after-linking-the-opencv-libraries-mat-objects-are-still-undefined -
wrote on 31 Aug 2023, 08:06 last edited by JonB
@Matiyash
This is C++ code, why are you posting in Qt for Python forum?I don't know anything about OpenCV. But your code shows a compilation error on the word
Mat
so far as I can see. That would have nothing to do with whether or not you are linking with something. It would imply you have not#include
d the right header file(s) orMat
is not right, e.g. perhaps it's defined in a namespace?UPDATE
Looking at the link you just posted, by the end you can see they usecv::Mat mat;
. That's just what I suggested: looks likeMat
is defined in acv::
namespace. Usecv::Mat QImage2MatColor()
or maybe introduceusing cv;
into your file to useMat
without the namespace in front of it. -
@JonB yes, I tried to include cv::, but what caused the expected namespace name error
and also why the error with the name of the function, use of undeclared identifier
wrote on 31 Aug 2023, 08:18 last edited by JonB@Matiyash
Like I said, I don't use OpenCV. Check it uses a namespace and what that name is. Maybe it'scv2
now, oropencv
? Surely it gives an example somewhere?What about trying the example at https://docs.opencv.org/3.0-beta/doc/tutorials/introduction/display_image/display_image.html (or equivalent for OpenCV 2.x if 3.0-beta is not suitable, it's what I came across Googling) to see if that works for you?
-
@JonB Thanks for the link, but probably not, it seems like Opencv is installed correctly, I probably have an error related to the paths to the libraries
wrote on 31 Aug 2023, 08:45 last edited by@Matiyash
Since you show compilation errors onlyINCLUDEPATH
is relevant, it has not got as far asLIBS
yet. If yourINCLUDEPATH
were wrong you would get errors on#include
lines but you do not. Your problem seems to beusing namespace cv
. Which is why I would test the sample code I linked, just to see whether it compiles. -
@Matiyash
Since you show compilation errors onlyINCLUDEPATH
is relevant, it has not got as far asLIBS
yet. If yourINCLUDEPATH
were wrong you would get errors on#include
lines but you do not. Your problem seems to beusing namespace cv
. Which is why I would test the sample code I linked, just to see whether it compiles. -
wrote on 31 Aug 2023, 09:09 last edited by
@Matiyash
LOL, like I said, I don't use OpenCV or try that example. I know nothing about the other errors it reports. But theusing namespace cv
has gone through without complaint, andMat
is accepted, so you ought be able to adapt that/get it working for your code. -
@Matiyash The first error message basically says that std::string is an int which is very strange. Did you redefine "string" somewhere? I would not use "use namespace", at least not for cv.
-
@Matiyash The first error message basically says that std::string is an int which is very strange. Did you redefine "string" somewhere? I would not use "use namespace", at least not for cv.
wrote on 31 Aug 2023, 11:30 last edited by@jsulm said in Why after linking the OpenCV libraries, Mat objects are still 'undefined'?:
Did you redefine "string" somewhere?
That seems impossible since the whole of the source file is shown, and it has nothing other than system
<...>
includes. And the error message states it is matching againststd::string
.....The OP was only supposed to be using that sample code to get either
cv::Mat
orusing namespace vc; Mat
working. -
S SGaist moved this topic from Qt for Python on 31 Aug 2023, 18:21
1/11