Hello, could someone explain me, how i could get OpenCvData to my Python Script, like the size of the Box of an detected Object. I tried around with the add.listener think and some oder combinations, but couldn't get the Data to be retreived in the Script so i could use it (for exemple simple printing it).
Im sorry for all the questions i am asking right now, but i am not familiar with such Data Structure and it's difficult for me to read the javadoc thing to get stuff going.
Thanks for your help.
Added example to Service page
Added example to Service page script:
http://myrobotlab.org/service/OpenCV
[[service/OpenCV.py]]
Thank you very much
Thank you for the quick and easy response. I wrote something similar, but didnt put "data" in the brackets at the input function for the message. =)
It would be very awesome if someone could explain me, why this is needed in this case, or when you have to pass something similiar to a function.
EDIT: If someone wants to do this with the opencv created by the tracking service, use:
opencv = tracker.getOpenCV()
Synchronous vs Asynchronous
Its the same data, but MyRobotLab allows you to interact with it Synchronously or Asynchronously.
Typically - Asynchronous is more like life :) Events happen, and we get notified versus polling and waiting for return data.
Many services produce data - and we don't know what schedule they are on, or when it will happen .. rather than poll data like this:
we simply let the Service produce the data and allow it to call our function.
But it takes 2 parts:
1 part to setup the "route"
this tells the OpenCV service when it's publishOpenCVData method is called route the returned data to python.onOpenCV(data)
Script structure
Ok good to know, but it leads me to another question, if i start programming for my robot, do i have a loop function where i can write for example the if commands, to tell what to do in what case, or do i put all this decisionmaking in functions like the onOpencvData we used now for each service? It seems more simple to do it 'the arduino-loop' way?
Its completely up to you.
Its completely up to you.
Your robot is a Finite State Machine .. like pretty much everything in the universe...
Most living things don't have a single loop :)
But a single loop does make programming easier to get started.... and you have to start somewhere