Ask Your Question

No SelectROI in OpenCV jar?

asked 2019-03-03 04:42:50 -0500

JacK gravatar image

updated 2019-03-03 05:21:33 -0500

I'm writing a small utility program that should crop images based on a rectangular shape that i want to input dinamically with the mouse, (as seen in this tutorial).
Unlike the tutorial, i'd like to implement this application in Java, as i'm more comfortable with it: I'm using NetBeans 10 and i've added the OpenCV 4.0.1 library (and the .dll in the root of the project, as I'm under Win10).

So far, when i invoked Imgcodecs and Imgproc methods or declared Mat type objects I've never had issues, but when i tried HighGui.selectROI() the IDE was not able to resolve its depencency: so i checked the JavaDOC for OpenCV 4, and indeed it's lacking the SelectROI method, while inside the cpp source that came alongside the library it's actually there, as well as reported by the C++/Python docs.

Here's what I came up with so far:
- either the SelectROI function was not ported to Java because there's a simple way of getting to the same result with minimal effort and I just need to read more stuff, in which case I'd like to be pointed to the right docs;
- or i need to rebuild the OpenCV jar, and export something to make it available to my other application, in which case i would need some basic guide as i couldn't make head or tail of the sources and the folder structure;
- or mabybe it's just a matter of doing some JNI wizardry, wich i know nothing about at the present time.

edit: typos

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-03-03 04:49:47 -0500

berak gravatar image

NONE of opencv's functionality from the highgui module is wrapped into java (you can't assume access to the underlying (os based) gui from java)

instead (as of opencv4) there is a "mock" highgui module in java, which tries to replicate the basic imshow() / waitKey() things with native java means

unfortunately, this does not go as far as simulating the selectROI() functions, you'll have to come up with your own replacement.

edit flag offensive delete link more


Thank you very much, is this detailed anywhere in the docs?

JacK gravatar imageJacK ( 2019-03-03 05:17:37 -0500 )edit

it's not really in the docs, but hidden in commits

berak gravatar imageberak ( 2019-03-03 05:56:11 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-03-03 04:42:50 -0500

Seen: 25 times

Last updated: Mar 03