i’m trying to write a unity plugin, which allows me to capture webcam input into a texture.
I chose OpenCV, so the plugin runs flawlessly on win and mac. On Windows theres no problem… just copy the dlls into the app-directory and everything works.
But is there a possibility to add the “OpenCV.framework” into my Mac standalone app, so that it’s automatically linked at runtime? Putting the framework inside the library folder would work, but I don’t like the idea of installing frameworks on other machines.
I dont have the answer - but I would sure love to take a look at the webcam plugin once its done. Will you be putting it on the Wiki, or is it proprietary?
You can put frameworks inside the application bundle, although they have to have been built to work in that way. You generally put them in Your.app/Contents/Frameworks.
This article from Apple and this one from CocoaDevCentral tell you where to put your frameworks in the application, and talks a bit about how you build them to work in that location. There’s a better Apple one somewhere, but I can’t seem to find it at the moment… maybe Google for it if you need more information.
The majority of developers build their frameworks to work inside the application bundle automatically, but sometimes this isn’t the case. If it doesn’t work, you have to either rebuild the framework in the correct way (with the INSTALL_PATH set to “@executable_path/…/Frameworks”), or you have to modify it using the libtool command from the Terminal. The latter route isn’t always possible.
I used the DotMac SDK framework in the Big Bang Brain Games in the manner Neil described. Simply have a script copy the framework into a build with a script:
Loran, is there anything special that has to be done to register the OpenCV1 dll, so that Unity can find it? I have been trying to test your project, and even though everything seems fine, when it runs Unity reports a “DllNotFoundException”. The strange thing is that the path where it is looking for the DLL is absolutely correct. So I am wondering if the DLL has to be “registered” with Mac OSX somehow (admittedly I am a Mac newbie, so apologies if this is a stupid question).
As a second question, do I need to download some other OpenCV files, or is everything already compiled into the OpenCV1 DLL?
omoymenya,
In fact, the plugin is linked to the openCV framework. There must be a way to compile the plug with the framework inside it but i don’t know how yet.
If think you have to download the openCV framework (compiled version), build a standalone(mac) and place the framework inside the package at Contents/Frameworks. It might work…
Thank you, Loran, that was exactly the help I needed.
I found a compiled version of OpenCV linked from the OpenCV website, and copied the OpenCV.framework files to the Contents/frameworks directory of my standalone Unity executable. After that the standalone app worked perfectly.
I tried to get it to work just in the Unity editor by copying OpenCV.framework to a couple of different places in the Assets and Library folders, but no luck there. Is there a way to get it to work in the editor?
Thank you, Loran, that was exactly the help I needed.
I found a compiled version of OpenCV linked from the OpenCV website, and copied the OpenCV.framework files to the Contents/frameworks directory of my standalone Unity executable. After that the standalone app worked perfectly.
I tried to get it to work just in the Unity editor by copying OpenCV.framework to a couple of different places in the Assets and Library folders, but no luck there. Is there a way to get it to work in the editor?
I don’t know because it must be linked from my builtin hierachy but you can try to copy the framework inside the bundle by creating a frameworks directory… Don’t have time for testing it now, but sure i will… :roll:
anyway, has i am not getting in buisness with my passions i will post the full plugin with camera to texture function and opticalFlow tracking function for free to the community once a day.
(before setpember i beleive)
Is there already anyone who succesfully implemented OpenCV (for video capture and video file playback) in Unity, and would like to share some examples and help?