Getting OpenCV framework installed correctly.

[quote=377086:@BenotBouillon]In the file “flip” there is a module “OpenCVX”, isn’t sufficient?
For example when I execute that file “flip” a class named “Auto” is not recognized.[/quote]
When OpenCV for Xojo was written Auto was not a word used by Xojo itself, so the author was free to use it for a custom class.

But in newer versions of Xojo Auto exists (its a replacement for Variant), so the custom class can no longer be called Auto.

You will need to replace all occurrences of Auto with something else, like Automatic.

The other possibility is that the code is newer than I thought and is using Auto in place of Variant, but you are using an old Xojo version that does not have Auto.

At least thats my guess.

Finally… Thank you.

[quote]
" Library not loaded: @executable_path/…/lib/OSX/libopencv_world.3.0.0.dylib"
What that is saying is that for your program to work it needs libopencv_world.3.0.0.dylib in a location that it could be found.

Take that and put in in a suitable location, for this discussion let’s use Users folder

So put libopencv_world.3.0.0.dylib in your Users folder

Now, in your project, you will find in the xTools module, “Constants”, add it there and compile your app and all should be well.
/users/libopencv_world.3.0.0.dylib instead of @executable_path/…/lib/OSX/libopencv_world.3.0.0.dylib[/quote]

Wow that is fast!

You should add a Copy step to a Folder named lib dragging the OS X folder starting from app.

Maybe better a copy step starting from Frameworks with only libopencv_world.3.0.0.dylib (taken from the OS X folder in lib)
e use @executable_path/…/Frameworks/libopencv_world.3.0.0.dylib

In this way your app will be portable, otherwise using a reference to /users/libopencv_world.3.0.0.dylib means that you have to copy this dylib to the user “users” folder before

Hello.

I have tried the examples and they work but I am not quite familiar with using this framework.

I can load an image in loadImage3.xojo_binary_project, in the samples/loadImage folder.

Can anyone provide a snippet of code that will identify the number people faces or some defined object in an image that was loaded?

That would be a great starting point for me.

Thanks.

Lennox

Try the hough transform of an image of a few straight lines.
Excellent and fast.

Thanks Brian but that is not what I want.

What I want is after a picture had been displayed if a button with the appropriate code is clicked a box is drawn enclosing each of the specified objects, e.g. faces of people that are in the picture.

https://www.google.com/imgres?imgurl=http%3A%2F%2F3.bp.blogspot.com%2F-WG6EDeuKHM8%2FVRKMG98t0WI%2FAAAAAAAABjc%2Fe9h5MKC-xCk%2Fs1600%2Fresult.jpg&imgrefurl=http%3A%2F%2Frpihome.blogspot.com%2F2015%2F03%2Fface-detection-with-raspberry-pi.html&docid=XizHWl69WfGfOM&tbnid=52vTz_aIPhH9PM%3A&vet=10ahUKEwiTvIihgerZAhXGxFkKHd9VCEkQMwhpKCYwJg..i&w=640&h=482&client=safari&bih=973&biw=1895&q=opencv%20detect%20faces&ved=0ahUKEwiTvIihgerZAhXGxFkKHd9VCEkQMwhpKCYwJg&iact=mrc&uact=8

Any other suggestions?

Thanks.

Lennox

Why don’t we start here and port the example code to Xojo.
OpenCV Face Detection

Hi Brian,

A working knowledge off OpenCV is required, which I do not have, so that functions can be called. I am trying to rectify that.

Lots of sample code can be found on the Internet but written in Python, so some knowledge in Python is required, not difficult to learn, I’ll have to learn that too.

Python scripts should be able to be called in Xojo.

So for me, I’ll need a “jump-start”, then I’ll be able to “fiddle around” that is how I have been able to learn Xojo, thanks to this forum, (all all the helpful people here), the “Listarchives”, and the “NUG”, I don’t know if they are still available.

Lennox

OK, Let’s get started…

In the “samples” folder there is a folder called “loadImage” and in that folder is a project called “loadImage3.xojo_binary_project”.

We can start with that.

Put “libopencv_world.3.0.0.dylib” in the “Users” folder
Open loadImage3.xojo_binary_project and configure OS X to “/users/libopencv_world.3.0.0.dylib”

Between the “Load and Convert Image” pushbutton and “Quit” pushbutton add a new Pushbutton and name it “Analyse Faces” or some other appropriate name to your liking.

In that Pushbutton “Mouse Down” event add some code to

  1. count number of male faces
  2. count number of femalemale faces
  3. count number of unidentified faces.
  4. Display the information in a message box.

After the project has been compiled, click the “Load and Convert Image” and navigate to a suitable image. e.g. http://libna.mntl.illinois.edu/images/group_photos_2014.png

It can be downloaded beforehand.

Click the “Analyse Faces” pushbutton and get the result in the message box.

How about that, no conversion from one language to Xojo, just plain Xojo.

Lennox

I’m sorry I thought you wanted to learn OpenCV under Xojo, not how to run demo apps under Xojo.
Best of luck,
B.

Hello and thank you all.
In fact it was enough to read the instructions but they were at the limit a little too detailed and induced a little confusion in any case for me.
For Windows users just indicate the path of the dll in the World constant located in the Tools module.
I thought my installation was not correct but it’s actually because my version of Realbasic is maybe too old.
Some commands were not interpreted by my current version.
To avoid cluttering this post I may ask these questions in a new post.
Again thanks to you.

Hey Everyone,
I am reopening this thread after almost two years.
I am facing the problem while using OpenCV and I don’t know how to proceed on it.

  1. I am unable to download OpenCV.3.0. I am able to locate it in the releases at opencv.org, but the windows package simply does’nt get downloaded.

  2. Further the instructions say, that we need to use OpenCV 3.0 should be 32bit. I don’t know, if the one I am trying to download is 32 bits and additionally both my Xojo variant is 64 bits and Windows is also 64 bits.

I shall be grateful if someone can help me on this.

Thanks

Try this link:
opencv-3.0.0.exe

The address has https://sourceforge.net/projects/opencvlibrary/files/opencv-win/3.0.0/opencv-3.0.0.exe/download I suppose that the correctt address is : https://sourceforge.net/projects/opencvlibrary/files/opencv-win/3.0.0/opencv-3.0.0.exe without: “/download”

Hello,

Thanks @Calvi Tecnologie srl Calvi ,

Really appreciate the help.

Regards
Gaurav

Hello Everyone,

With the inputs from @Calvi Tecnologie srl Calvi , I have been able to to load OpenCV into Xojo.

I tried with the Hough example from the sample folder, and by selecting an image on my PC, I get great Hough Lines.

However, when I tried with Camera example, upon executing the sample file, it switches on default laptop built-in camera,

but the video on the screen is all black for the camera motion example and all white for the camera example.

Any idea how to try the samples.

PS - I haven’t yet installed ffmpeg seperately. Don’t know if thats related to the above problem in any way.

Thanks…

Hello,
I like to use OpenCV with xojo with my Raspberry 4 but they give me an error when I use the camera examples. They run on my mac but not on the Raspberry Pi 4.
How could I solve this problem. Thank you for any help!

You can start by showing your code and the error.