NO

Author Topic: OpenCV - Help compiling the libraries  (Read 9252 times)

Chynthlis

  • Guest
OpenCV - Help compiling the libraries
« 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
« Last Edit: June 07, 2012, 06:41:08 PM by Chynthlis »

CommonTater

  • Guest
Re: OpenCV - Help compiling the libraries
« Reply #1 on: June 07, 2012, 07:21:50 PM »
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".

 
« Last Edit: June 07, 2012, 07:35:32 PM by CommonTater »

migf1

  • Guest
Re: OpenCV - Help compiling the libraries
« Reply #2 on: June 07, 2012, 08:22:11 PM »
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.

migf1

  • Guest
Re: OpenCV - Help compiling the libraries
« Reply #3 on: June 07, 2012, 08:52:00 PM »
I had a quick look (just before leaving work, going home) and I found this: 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 )
« Last Edit: June 07, 2012, 08:53:40 PM by migf1 »

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: OpenCV - Help compiling the libraries
« Reply #4 on: June 08, 2012, 04:44:55 PM »
I had a quick look (just before leaving work, going home) and I found this: 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

migf1

  • Guest
Re: OpenCV - Help compiling the libraries
« Reply #5 on: June 08, 2012, 04:54:32 PM »
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.

CommonTater

  • Guest

CommonTater

  • Guest
Re: OpenCV - Help compiling the libraries
« Reply #7 on: June 08, 2012, 08:43:54 PM »
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.




migf1

  • Guest
Re: OpenCV - Help compiling the libraries
« Reply #8 on: June 08, 2012, 08:54:17 PM »
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/

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)
« Last Edit: June 08, 2012, 08:58:06 PM by migf1 »

Offline AlexN

  • Global Moderator
  • Member
  • *****
  • Posts: 394
    • Alex's Link Sammlung
best regards
 Alex ;)

Chynthlis

  • Guest
Re: OpenCV - Help compiling the libraries
« Reply #10 on: June 08, 2012, 09:55:01 PM »
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
« Last Edit: June 08, 2012, 10:01:35 PM by Chynthlis »

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2107
Re: OpenCV - Help compiling the libraries
« Reply #11 on: June 08, 2012, 10:07:07 PM »
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:
Code: [Select]
////////////////////////////////////////////////////////////////////////
//
// 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:
Code: [Select]
PellesC7\Include\xmmintrin.h(10): fatal error #1035: Can't find include file <mmintrin.h>

« Last Edit: June 08, 2012, 10:37:04 PM by timovjl »
May the source be with you

Chynthlis

  • Guest
Re: OpenCV - Help compiling the libraries
« Reply #12 on: June 08, 2012, 10:09:13 PM »
Hi timovjl,

Where did you find DLLs for the newer revisions of the libraries?

-Reg

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2107
« Last Edit: June 09, 2012, 12:35:40 PM by timovjl »
May the source be with you

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: OpenCV - Help compiling the libraries
« Reply #14 on: June 17, 2012, 12:48:21 PM »
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...
/Pelle