opencv.addListener

Some help here guys, please.

When I try to run any script with the line:
opencv.addListener("publish", python.name, "input", OpenCVData().getClass()) 
 
I get these warnings:
 
21693 [opencv] WARN  class org.myrobotlab.framework.Service  - OpenCV.setState(OpenCV) :  NoSuchMethodException - attempting upcasting
21694 [opencv] WARN  class org.myrobotlab.framework.Service  - ouch! need to search through 173 methods
21703 [opencv] INFO  org.myrobotlab.opencv.VideoProcessor  - starting capture
21705 [opencv_videoProcessor] INFO  org.myrobotlab.opencv.VideoProcessor  - using com.googlecode.javacv.OpenCVFrameGrabber
 
and the script stops...
GroG's picture

Hello Paulo ! Like your

Hello Paulo !

Like your Avatar ! ;)

You don't get a video stream ?  Unfortunately, the warning that you listed would not result in your problem. Although it's nice you looked into the log.  

Just so you know, the warning is a reminder to me that the frameworks dynamic upcasting is not as optimized as it could be.  It has nothing to do with the lack of a video stream.

Can you send a No-Worky - http://myrobotlab.org/content/helpful-myrobotlab-tips-and-tricks-0#noWorky

This will allow me to see the whole log file.

pauloSouza's picture

No-Worky Sent

GroG,

Tks for the rapid response (as always).

I sent you the "No-Worky".

In Python scripts,

When I use the CvPoint (like bellow), the listener doesn't work, but the script goes until the end.

opencv.addListener("publish", python.name, "input", CvPoint().getClass()) 
 
But when I use OpenCVData, the script stops there.
 
The Python Tracking/OpenCV script works fine and also the OpenCV service without Python.
 
I was testing in an Intel Atlon, but now I'm using my i5 home computer and the results are the same.
 
GroG's picture

you can't construct an

you can't construct an OpenCVData without a "name" .. e.g. OpenCVData("someName")

In the No-Worky log I can see your script - and in it, there is this line..

opencv.addListener("publish", python.name, "input", OpenCVData().getClass()) 

this is supposed to be telling opencv that there is a listener named (python.name) and every time it invokes the "publish" method it should return the resulting data to python.input.....

You don't want "publish" anyway for OpenCVData ...

try this 

opencv = Runtime.createAndStart("opencv","OpenCV")
opencv.addFilter("PyramidDown")
opencv.addFilter("FaceDetect")
opencv.setDisplayFilter("FaceDetect")
 
opencv.addListener("publishOpenCVData", python.name, "input") 
 
 
def input():
    data =  msg_opencv_publishOpenCVData.data[0]
    bb = data.getBoundingBoxArray()
    print 'opencv data ', bb
    for rect in bb:
      print "face found in rectangle ", rect.x, rect.y, rect.width, rect.height
 

it should give the following output

 

pauloSouza's picture

Yeah! That works!

Thanks again GroG.

the_Z0MBiE's picture

[python.input] [ERROR] python error PyException null

Hey GroG,

I am running MRL 1.0.2652 on Windows 7 64-bit OS. When I run the code, my face is detected and bound by a red square, but I'm unable to get the coordinates. 

I have used OpenCV with Python but am only 4 days old on MRL. Please help. I have already sent a 'no-worky'!

Thanks a lot for your help!