Contours2 not working [closed]

asked 2018-11-17 17:37:43 -0600

Aquatica1000 gravatar image

I've been working on using OpenCV with regards to a school project. I've downloaded and installed it onto my computer, set it up to work with Dev-C++ 5.11, and tried to run the contours2 cpp sample to make sure I had everything working as planned. Unfortunately, I have received the error "'Mat' in namespace 'cv' does not name a type," originating in the "types" header. While I am somewhat knowledgeable in C++, I am new to OpenCV and not entirely sure how to fix this without inadvertently messing things up further. Does anyone have suggestions?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-07 19:12:40.678451

Comments

Could you please include your source code in your question?

sjhalayka gravatar imagesjhalayka ( 2018-11-17 19:42:34 -0600 )edit

I was using the contours2 example from the OpenCV library, as well as the headers that are referenced in it (core, opencv, utility, cvdef, highgui, highgui_c, imgproc, imgproc_c, and types_c). The error shows up in the types_c header. As there's so much ground to cover I wasn't sure how to upload it, as .zip files aren't allowed for upload. Sorry...

Aquatica1000 gravatar imageAquatica1000 ( 2018-11-17 19:52:46 -0600 )edit
1

note, that the contours2.cpp does NOT include any xx_c.h headers

berak gravatar imageberak ( 2018-11-17 20:39:44 -0600 )edit

I understand that much. The only one that contours2 explicitly included was imgproc. But imgproc included some other headers, and some of them included more. All those headers I mentioned were the ones that showed up when I tried to compile contours2.

Aquatica1000 gravatar imageAquatica1000 ( 2018-11-17 20:45:58 -0600 )edit

I've downloaded and installed it onto my computer,

what exactly did you do here?

devcpp usually comes bundled with an (outdated) mingw compiler, to use that, step #1 would have been building the opencv libs from src (the prebuilt libs are for VisualStudio only)

berak gravatar imageberak ( 2018-11-18 01:37:04 -0600 )edit

is there any chance, you can use VisualStudio instead of devcpp ?

berak gravatar imageberak ( 2018-11-18 05:35:18 -0600 )edit

The library is only for Visual Studio? I guess that explains why it looked weird when I opened it in Dev-C++. But how do I make a library compatible with Dev-C++? I've never used Visual Studio before and I'm already having a hard time learning OpenCV without learning to use an entirely new software.

Aquatica1000 gravatar imageAquatica1000 ( 2018-11-18 06:54:17 -0600 )edit

you seem to underestimate the problems ahead. support for mingw has been dropped many years before, and building libs from src is not a piece of cake for a noob (esp. if i look at the question, and the comments above)

berak gravatar imageberak ( 2018-11-18 07:43:37 -0600 )edit
2

I guess I'll try again with setting it up for Visual Studio, then. I'm kind of on a time limit with this project, and the more I can get done quickly, the better.

Aquatica1000 gravatar imageAquatica1000 ( 2018-11-18 08:44:56 -0600 )edit
1

Yes, VS Community Edition 2017 is free, and it works with the prebuilt OpenCV libraries (it's how I installed OpenCV on both of my Windows machines). See: https://opencv.org/releases.html --> (3.4.3) Win Pack.

sjhalayka gravatar imagesjhalayka ( 2018-11-18 11:12:13 -0600 )edit