Page 1 of 1

Someone tried OpenCV (Computer Vision Library) with Servoy?

PostPosted: Sat Mar 16, 2019 9:43 pm
by ProRM
Hi,

Someone ever tried to use OpenCV in Servoy? OpenCV is an Open Source Computer Vision Library to recognize forms, colors, faces and more. It is written in C/C++ but has C++, Python and Java interfaces. We have two project that need different types of image recognition and if we can not use Servoy we should go with Python.

Regards

Re: Someone tried OpenCV (Computer Vision Library) with Serv

PostPosted: Mon Mar 18, 2019 3:14 pm
by sean
Hi Juan,

Anything with a Java interface should be usable in Servoy. Do you have the library as .jar files ?
Placing them in the /application_server/beans folder should make them accessible. You can call the classes directly from javascript editor (You even get code complete!)

Code: Select all
Packages.<my-package>.<my-class>

i.e.
Code: Select all
var thing = new Packages.com.uraburu.MyClass(someArg);

Re: Someone tried OpenCV (Computer Vision Library) with Serv

PostPosted: Tue Mar 19, 2019 2:58 am
by ProRM
Hi Master Sean,

Attached please find opencv-401.jar. The installation also contains two folders x86 and x64 including the corresponding dll file as OpenCV is built in C/C++. I copied the jar and both folders into beans folder. I am trying to figure out what the name of the Package is.

Regards!

Re: Someone tried OpenCV (Computer Vision Library) with Serv

PostPosted: Tue Mar 19, 2019 4:24 am
by sean
Hi Juan,

Do you have documentation or examples? (There are probably a lot of packages and classes in the jar file)
Something like this ?
https://opencv-java-tutorials.readthedo ... pencv.html

Re: Someone tried OpenCV (Computer Vision Library) with Serv

PostPosted: Wed Mar 20, 2019 2:57 pm
by ProRM

Re: Someone tried OpenCV (Computer Vision Library) with Serv

PostPosted: Thu Mar 21, 2019 5:06 pm
by sean
Hi Juan,

You have to translate it into javascript wrappers which is not as hard as it sounds. And the process is the same for anybody who wants to call Java from Servoy.

1. You see the import statements at the top of the java example - those give you the java package names.
You must use these package names when you reference a class from the library, i.e.
Code: Select all
import org.opencv.core.Point


2. Whenever a java class is referenced you will use the fully qualified class name, including Packages.<package-name>.<class-name>, i.e.
Code: Select all
Point
becomes
Code: Select all
Packages.org.opencv.core.Point


3. Java requires that variables are declared with the class/type, i.e.
Code: Select all
String foo = "bar"

becomes
Code: Select all
var foo = "bar"


For example from your library:
Code: Select all
Point pt = new Point();
pt.x = 10;
pt.y = 8;


becomes:
Code: Select all
var pt = new Packages.org.opencv.core.Point();
pt.x = 10;
pt.y = 8;


hope this helps.

Best,
Sean

Re: Someone tried OpenCV (Computer Vision Library) with Serv

PostPosted: Wed Apr 03, 2019 5:04 am
by ProRM
You are the one Sean (and you know it!)