Pelles C forum
C language => Beginner questions => Topic started by: Chynthlis on June 07, 2012, 06:36:33 PM
-
Hi All!
I'm hoping I can get some help, building the OpenCV (Open-Source Computer Vision) libraries for Pelles C. A good link to the code:
http://opencv.willowgarage.com/wiki/InstallGuide
OpenCV seems to have prebuilt libraries for MS Visual Studio and MingWin. I'm pretty sure I can't just use either of these libraries, right?
I'm working with a Win7 64bit system.
Any advice or information you can off is appreciated.
Thanks,
-Reg
-
If the prebuilts are in DLL form, you should be able to use them like any other DLL so long as they have a "C Interface". (i.e. no classes or OOP). (Hint, Windows DLLs are MSVS Dlls, actually produced by MSVC++)
If you are wanting to compile it yourself, you will need to put it into a directory by itself, then create a Pelles C static or dynamic library project, import the source into the project and get ready to sweat your way through lots and lots of issues... They claim C code is portable... They lied.
EDIT: That may sound overly negative... but this kind of thing never "just works".
-
Compiling the sources with Pelles C is unfortunately out of the question, since the API is written in C++.
However, following CommonTater's hints for just linking the library binaries (provided they are available) and then searching the docs of the API for how to use the C interface (I read there is one) you should be able to use the API in your projects.
PS. I also read that v1.xx of the API was written in C, but I seriously doubt you should go that route.
-
I had a quick look (just before leaving work, going home) and I found this: http://opencv.willowgarage.com/wiki/DevCpp (http://opencv.willowgarage.com/wiki/DevCpp)
It's marked as outdated, but I it gives you a clear outline on what libraries and header files you should include in your Project Options under Pelles C, in order to use OpenCV calls. But you still need to find the latest binaries.
From the little browsing I did, it seems that v1.x of OpenCV is still a liable option, so if you don't find pre-compiled, C specific, libs for the latest version, you can have a go with the previous version, which was written in C. Chances are you'll find precompiled libs there (if not, the sources are in C, so you can compile them yourself with Pelles C )
-
I had a quick look (just before leaving work, going home) and I found this: http://opencv.willowgarage.com/wiki/DevCpp (http://opencv.willowgarage.com/wiki/DevCpp)
Don't know where you got that link from, as it isn't even the original Bloodshed site, but Dev-C++ is still being maintained (so stated as "unofficial", due to none of the original authors responding to requests) and can be found at
http://orwellengine.blogspot.com
The latest version (5.2.02) is from May 31st 2012...
Ralf
-
I got the link from google, when looking for "opencv +binaries +c " (or something like that, I don't remember exactly).
PS. Actually I'm aware of the "unofficial" Orwell Dev-C++, but the point was to help Chynthlis in his effort to use OpenCV with Pelles C.
-
http://orwellengine.blogspot.com
Moved to .... http://orwelldevcpp.blogspot.ca/
Follow the bouncing ball....
-
This I think, will answer the question of why it's not going to compile on Pelles C...
http://code.opencv.org/svn/opencv/trunk/opencv/modules/core/src/
Yep... it's C++ code.
In case our friend Cynthlis doesn't know (although I expect he does) C and C++ are two completely different languages. While C++ compilers will compile some (but not all) C code... a C compiler will look at C++ code in awe and bewilderment.
-
Yeap! :)
If the topic-starter is still interested, here is version 1.0 of the API (both sources & binaries in C):
https://sourceforge.net/projects/opencvlibrary/files/opencv-win/1.0/ (https://sourceforge.net/projects/opencvlibrary/files/opencv-win/1.0/)
EDIT:
My bad, the 1st file is for the Ch (a popular C interpreter). The 2nd file is the one he's looking for, but I don't know if the installer installs both binaries and sources. He has to download it and check for himself ( I haven't)
-
http://orwellengine.blogspot.com
Moved to .... http://orwelldevcpp.blogspot.ca/
Follow the bouncing ball....
I am far off topic, but an other mirror of this is http://orwelldevcpp.blogspot.co.at/ (http://orwelldevcpp.blogspot.co.at/). ;)
-
Thank you everyone. I really appreciate the responses.
So, what I gather from your responses, I will only be able to use the 1.x version of OpenCV because it is written in C, and 2.x is written in C++. (And yes, I do know C and C++ are different. I have worked with 1.x a bit, and didn't realize they moved the library to C++ for 2.x)
I have looked and found that OpenCV is not compiled into DLLs. I wonder if that shouldn't be a project. It could make things much easier for developers. I will bring it up on the OpenCV forums.
I have not had a chance to look through the recent links posted so I will check those out.
Again, thank you. I will check back often to see if there is any new insight.
-Reg
-
It is possible to compile program that use OpenCV dll's with PellesC.
I test versions 2.3.0 and 2.4.0 with this test program:////////////////////////////////////////////////////////////////////////
//
// hello-world.c
//
// This is a simple, introductory OpenCV program. The program reads an
// image from a file, inverts it, and displays the result.
//
////////////////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#ifdef _WIN64
#include <xmmintr.h>
#include <emmintrin.h>
#endif
//#include <cv.h>
#include <highgui.h>
int main(int argc, char *argv[])
{
IplImage* img = 0;
int height,width,step,channels;
uchar *data;
int i,j,k;
if(argc<2){
printf("Usage: main <image-file-name>\n\7");
exit(0);
}
// load an image
img=cvLoadImage(argv[1], CV_LOAD_IMAGE_COLOR);
if(!img){
printf("Could not load image file: %s\n",argv[1]);
exit(0);
}
// get the image data
height = img->height;
width = img->width;
step = img->widthStep;
channels = img->nChannels;
data = (uchar *)img->imageData;
printf("Processing a %dx%d image with %d channels\n",height,width,channels);
// create a window
cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
cvMoveWindow("mainWin", 100, 100);
// invert the image
for(i=0;i<height;i++) for(j=0;j<width;j++) for(k=0;k<channels;k++)
data[i*step+j*channels+k]=255-data[i*step+j*channels+k];
// show the image
cvShowImage("mainWin", img );
// wait for a key
cvWaitKey(0);
// release the image
cvReleaseImage(&img );
return 0;
}
Oops:PellesC7\Include\xmmintrin.h(10): fatal error #1035: Can't find include file <mmintrin.h>
-
Hi timovjl,
Where did you find DLLs for the newer revisions of the libraries?
-Reg
-
http://sourceforge.net/projects/opencvlibrary/files/opencv-win/
version 2.3:
http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3/OpenCV-2.3.0-win-superpack.exe/download
-
I install a very old mmintr.h (for MMX) with Pelles C, but also have a mmintrin.h file on my disk - which is basically the same useless file (no MMX intrinsics).
The name mmintrin.h is more standard, but apparently not included in the Setup. I will add this to file RC4 just to be complete...