openCV contourFinder broken with 0.03 ?

I downloaded the opencv addons again just to be sure, created a new project and added everything properly. When I try to compile it says…

1>ofCvGrayscaleImage.cpp
1>c:\openframeworks\v0.03\addons\ofopencv\ofCvContourFinder.h(15) : error C2061: syntax error : identifier ‘ofCvGrayscaleImage’
1>c:\openframeworks\v0.03\addons\ofopencv\ofCvContourFinder.h(24) : error C2146: syntax error : missing ‘;’ before identifier ‘inputCopy’
1>c:\openframeworks\v0.03\addons\ofopencv\ofCvContourFinder.h(24) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\openframeworks\v0.03\addons\ofopencv\ofCvContourFinder.h(24) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

ofCvMain looks like this, so contourfinder should know what a greyscale image is :frowning:

  
  
#ifndef _CV_MAIN_H  
#define _CV_MAIN_H  
  
  
//--------------------------  
// constants  
#include "ofCvConstants.h"  
  
//--------------------------  
// images  
#include "ofCvGrayscaleImage.h"  
#include "ofCvColorImage.h"  
  
//--------------------------  
// contours  
  
#include "ofCvContourFinder.h"  
  
#endif  
  

What am I forgetting to do that I already did last time?

Thanks

Here is my project structure

Here is my folder structure

Here is the project settings showing the paths is correct for the include

Within ofAddons.h I am including ofCvMain.h

ofCvContour includes the following:
#include “ofMain.h”
#include “ofCvConstants.h”
#include “ofCvGrayscaleImage.h”

Any ideas?

hey chris, I know it’s probably massive, but can you post it so i can take a look? I bet it’s something small, but hard to see from here. I don’t think 0.02->0.03 changed anything big, so I think it’s just a path issue…

  • z

Here is the project file
http://www.chrisoshea.org/storage/ofw/e-…-Addons.zip

(it includes opencv, ofXML and memoryMovieMaker addons)

The opencv I have not uploaded as it is exactly the same as downloaded from addon page.

The error I get are:
1>c:\openframeworks\v0.03\addons\ofopencv\ofCvContourFinder.h(16) : error C2061: syntax error : identifier 'ofCvGrayscaleImage’

1>c:\openframeworks\v0.03\addons\ofopencv\ofCvContourFinder.h(25) : error C2146: syntax error : missing ‘;’ before identifier 'inputCopy’

1>c:\openframeworks\v0.03\addons\ofopencv\ofCvContourFinder.h(25) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

1>c:\openframeworks\v0.03\addons\ofopencv\ofCvContourFinder.h(25) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

I also get a warning (but not an error) on ofXML, but that is maybe a suggestion for later
1>…\addons\ofXML\xmlParser.cpp(311) : warning C4267: ‘return’ : conversion from ‘size_t’ to ‘int’, possible loss of data

Many thanks

hi chris,

can you zip everything in the folder structure?

I want to recreate exactly what you have so the best is to zip

libs
addons
apps

(with just one app, if you can)

what you posted is just a project but I want to have your whole structure so that what I have to do to see your error is try to compile.

many thanks
zach

Hmm, the whole folder is 300mb. Here is a version with the main libs from ofw stripped out (as I’ve not touched those anyway)

http://www.chrisoshea.org/storage/ofw/folder.zip - 4mb

(will delete once you have downloaded)

ok I see the problem.

there is a kind of recursive linking issue that I didn’t expect, and we will have to imagine a better solution, basically the problem is this

ofMain includes ofAddons
ofAddons includes ofCv
classes in ofCv include ofMain (to have access to textures, etc)

I think we didn’t think through everything yet –

a temporary fix

remove “ofAddons.h” include from ofMain
throw it in wherever you need it, ie:

testApp.h:
include “ofMain.h”
include “ofAddons.h”

a better fix

my first thought about what we are going to do is perhaps have three h files:

ofCore.h (includes all core code)
ofAddons.h (includes all addons)
ofMain.h (includes ofCore and ofAddons)

all the core code will use ofCore, all addons will use ofCore, and all your code will use ofMain.h, so that you can get both core and addons.

thanks for being patient, we have alot of things to iron out :slight_smile:

zach

No worries, I’m glad I can help contribute to you finding things :slight_smile:

I think that sounds like a good idea. I was going to suggest that ofAddons.h be project specific anyway. Otherwise you have to include all the addons libraries and links for every project, even if you don’t want to use those addons.
What do you think?

Doing the temporary fix, these are the errors:

1>Linking…
1>ofCvColorImage.obj : error LNK2001: unresolved external symbol _cvCreateImage
1>ofCvColorImage.obj : error LNK2001: unresolved external symbol _cvSetData
1>ofCvColorImage.obj : error LNK2001: unresolved external symbol _cvReleaseImage
1>ofCvContourFinder.obj : error LNK2001: unresolved external symbol _cvFindContours
1>ofCvContourFinder.obj : error LNK2001: unresolved external symbol _cvCreateMemStorage
1>ofCvContourFinder.obj : error LNK2001: unresolved external symbol _cvMoments
1>ofCvContourFinder.obj : error LNK2001: unresolved external symbol _cvBoundingRect
1>ofCvContourFinder.obj : error LNK2001: unresolved external symbol _cvArcLength
1>ofCvContourFinder.obj : error LNK2001: unresolved external symbol _cvReleaseMemStorage
1>ofCvContourFinder.obj : error LNK2001: unresolved external symbol _cvContourArea
1>ofCvContourFinder.obj : error LNK2001: unresolved external symbol _cvStartReadSeq
1>ofCvContourFinder.obj : error LNK2001: unresolved external symbol _cvChangeSeqBlock
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvCountNonZero
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvDilate
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvSet
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvFlip
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvSub
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvAbsDiff
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvCvtColor
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvSetZero
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvSetImageROI
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvAdd
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvMinMaxLoc
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvErode
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvConvertScale
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvResetImageROI
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvThreshold
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvWarpPerspective
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvReleaseMat
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvCreateMat
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvWarpPerspectiveQMatrix
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvSmooth
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvMul
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvAddS
1>ofCvGrayscaleImage.obj : error LNK2001: unresolved external symbol _cvCopy
1>Release\openFrameworksApp.exe : fatal error LNK1120: 35 unresolved externals

now you have to include the opencv libraries in the linker

(follow all the steps in the “readme” file in the opencv addon download)

-z

we are going to do it , I think, like this:

you build out your ofAddons.h file in the following way:

#ifdef USING_OFADDON_OPENCV
#include “ofCvMain.h”
#endif

then, in your code, at the top of the h file, when you need to, you can write:

#define USING_OFADDON_OPENCV
#define USING_OFADDON_XML

#include “ofMain.h”

this has the benifit of allowing you to do per-project choices of what you want to use, and to not use all of the addons that you put in. it also clearly identifies in your code which addons your used so that it might be easier to recreate your project. the downside is some weirdness with #defines (as we see above, the more #inlcudes we have, the more chances for recursive inlcudes and stuff like that).

this is our current plan we are working on but very open to suggestions from folks. it’s gonna take some playing this next weeks to see how addons can work well but we are excited to open up the of codebase and we have alot of good addons already done to post and in the works…

thanks!
zach

[quote author=“zach”]now you have to include the opencv libraries in the linker
[/quote]

I always forget to add cv.lib and cxcore.lib in the linker. This now compiles, thanks.

I’ve also put cv097.dll and cxcore097.dll into \other\dlls\ so that they are copied when you compile like the other libraries. Maybe this should be part of the install instructions for addons using dlls.

cool -

the downside of doing that is you will get the cv.dll for all of your apps, not just the ones that use opencv. if you don’t mind then put it in that folder, but I could see that getting pretty big with alot of addons…

great , glad it works!!
zach