How to use openCV in Xamarin? - opencv

I am creating a Xamarin project to detect some objects in images .
I want to use openCV library , but I can't wrap it to the xamarin .
I wrapped it to an windows form application but I can not wrap it to Xamarin (I got errors in compatibility)
I have tried to install EMGU.cv but I got error : unable to find version 3.4.3
also I can't update it .
I also tried to wrap the openCV to xamarin by downloading the openCV from here https://opencv.org/releases/
but I didn't find the the .jar file to add it the my project .
so how can I use openCV in xamarin please ?
also is object detection applicable with openCV or not ?

Luckily there is some work done by people before you. You can already use the wrapper that's created for Android, but for iOS you'll have to try to create the wrapper yourself
Edit from 2022: For Android you can also take a look at this GitHub sample, amongst many others

Related

need help regarding Markerless example using opencv for unity

I am working on project which is based on markerless technology so for this right now I am using opencv for unity and well known unity asset "Markerless example using opencv for unity" so after importing both packages it's showing one error of coremodule. I tried as much as i can but now I need help so i can proceed further to achieve my target.
here I am attaching the error that i am getting!!
enter image description here
This is because the plugin not successfully installed or imported or you're using outdated. Because new update of opencv for unity is just awesome. Do import it again or else you need to manually import classes by going to core module.

How to get the ImageMagick library working with Swift 4/iOS 11?

I'm trying to get ImageMagick to work in my iOS project. Unfortunately everything I have tried so far has not worked.
Cocoapods
The most obvious approach would be to use the cocoapod. Unfortunately after installing the cocoapod there doesn't appear to be anything exposed to swift to import. Maybe I'm missing something obvious and if anyone has any ideas that would be great. Unfortunately the documentation is lacking as far as specific examples go.
Static library - approach #1
The official ImageMagick docs provide some instructions to compile the latest version of ImageMagick and include a static library in your Xcode project. Unfortunately the first step of the instructions requires running a bash script imagemagick_compile.sh which I cannot find. Once again I could be missing something obvious.
Static library - approach #2
After some additional searching I found the ~Claudio guy which the ImageMagick docs mention as the maintainer of the iOS version of ImageMagick. He has a repo with similar instructions as provided by ImageMagick but this repo includes a bash script to compile and generate a static library of ImageMagick. I tried running the script directly ./all.sh 6.8.8-9 but soon realized I hadn't setup a build directory they way his instructions outlined and I got stuck getting libpng installed correctly.
Static library - approach #3
The same repo with the instructions to compile and generate a static library also includes an old sample iOS project with a static library already included for an older version of ImageMagick. This just about worked except the ImageMagick library has a class Timer that clashes with the Timer class provided by Swift4/iOS so I couldn't get my project to compile using this static library of ImageMagick.
ImageMagick iOS Questions on SO
There are a handful of other questions on Stack Overflow that deal with running ImageMagick on iOS so I know other people have done it but nothing very recent. If anyone has any ideas that would be greatly appreciated, thanks!
Un-answered question on how to use ImageMagick on iOS: ImageMagick iOS image Potentially useful comment that includes some of the same links that I provided above.
Someone already using ImageMagick for iOS but gives no details on how it was implemented: ImageMagick circular dstortion on iOS
Un-answered question from someone already using ImageMagick in their app: Ios - ImageMagick - No Image Created after Distortion
More recent question related to warnings using the cocoapod version: iOS: ImageMagick compiler warnings in Xcode
Other questions: https://stackoverflow.com/search?q=imagemagick+ios Unfortunately I haven't found any of these that have helped.
To integrate ImageMagick into iOS you will need to do the following:
Install the library available here https://www.imagemagick.org/download/iOS/
You will need a Swift-Objective-C bridging header that includes:
#import "ImageMagick.h"
#import "MagickWand.h"
You will need to modify any functions that reference Timer to Foundation.Timer, this will resolve any conflicts with the ImageMagick library
You will need to add under Your target > Build Phases > Link Binary With Libraries > "libxml2.tbd".
Hope this helps

Cannot compile OpenCV for iOS with nonfree module

I'm attempting to compile the OpenCV framework for iOS using the nonfree module. Right now, I'm not able to compile the OpenCV framework, period. I would use the stock iOS opencv2.framework download from the website, except it doesn't include the nonfree module that I need for my project. I've been following the instructions as prescribed here:
http://answers.opencv.org/question/61663/how-to-make-opencv2framework-with-opencv_contrib/
as these appear they might be out of date
http://docs.opencv.org/2.4/doc/tutorials/introduction/ios_install/ios_install.html
https://github.com/Itseez/opencv/issues/4712
However, when I run the command from a folder outside the building directories "python opencv-master/platforms/ios/build_framework.py --contrib opencv_contrib-master ios_contrib" it spits out the following error:
http://pastebin.com/LUep8Tdw
The error doesn't mean much to me. I thought at first it was related to me building it inside the same directory as opencv, but I tried it outside of it and it still failed. Any thoughts? I've tried everything I can possibly think of, and done a bunch of research without coming up with anything.
It appears there's some issue with one of the modules in opencv_contrib. I'm not sure what it is, but I was using version 3.0.0-rc-1. The way I got around it was by moving specific modules from the module folder in the contrib folder into the regular opencv directory's modules folder and then compiling the framework from scratch.

Binding Tesseract as a static Lib in Xamarin

I am trying to add tesseract to my iOS-App. Im doing the App with Xamarin.iOS.
I tried creating a .dll with btouch and used for that the ported version of tesseract on github(https://github.com/gali8/Tesseract-OCR-iOS). I created the bindings of tesseractOCR.h with Objective-Sharpie and created a
.dll with the TesseractOCR.a file.
Everything worked fine but when trying to build my app with the .dll referenced it gives me the attached Errors.
https://www.dropbox.com/s/w9cvzozgw4gffdx/Screen%20Shot%202014-03-31%20at%2012.46.24.png
How can I fix them?
Thanks in advance
Alex
This seems a good question and I came here looking for Xamarin bindings for Tesseract library, but there was none on this page. After searching, I found that there are a couple of bindings already for Xamarin:
Classic
1. https://github.com/sraiteri/Xamarin-Tesseract-OCR-iOS
Unified
2. https://github.com/jherby2k/Xamarin-Tesseract-OCR-iOS-Unified
Xamarin Forms
3. https://github.com/halkar/Tesseract.Xamarin
Also, there seems to be an active and modern porting to swift, and can be found here:
https://github.com/WhitneyLand/SwiftOpenCV
This discussion on Xamarin forum seems also very useful for anybody interested in this question:
https://forums.xamarin.com/discussion/3673/help-adding-tesseract-as-a-ios-binding-project
Disclaimer: I have not tried any of them yet, just finished my research, now gonna start my experimentation :)
This is because Tesseract uses c++ and the binding needs to know this.
I would suggest creating a binding project as per the tutorial at Xamarin. Then this Xamarin forum post gives great information on how to add c++ to the LinkWith attribute.

Implementing ASIFT in Android

I am new to both openCV and Android. I have to detect objects in my project. So, I have decided to use ASIFT for the same. However, the code they have given here is very lengthy. It contains lots of C file. It also doesn't have openCV support.
Some search on the SO itself suggested that it is easier to connect the ASIFT code to the openCV library, but I can't figure out how to do that. Can anyone help me by giving some link or by telling the steps that I should use to add ASIFT to my openCv library, which I can further utilize in making my Android application?
Also, I would like to know whether using Android NDK along with JNI to make calls to the C files or using Android SDK along with binary package for my android project(Object Detection) would be a suitable option for me?
Finally , I solved my problem by using the source code given at the website of ASIFT developers. I compacted all the source files together to make my own library using make. I then called the required function from the library using JNI.
It worked for me, but the execution is taking approximate 2 mins on an Android device. Anyone having some idea about ways to reduce the running time ?
They used very simple and slow brute force matching (just for proving of concept). You can use FLANN library and it will help a lot. http://docs.opencv.org/doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.html

Resources