I downloaded myrobotlab 14.9 and ran the bat file. The application worked fine but when I am trying to install/download services like arduino there are some errors like: need to reinstall processing. I'm just wondering if that version of myrobotlab is supported in 64 bit version OS/machine. BTW, my OS is Windows 7 Ultimate 64 bit. Anyway, I will try to use it in windows xp 32 bit.

GroG

10 years 1 month ago

Hello michael96_27,

Yes, it appears rather "goofed up" in 14.9 on Windows.  It's the integration of the Arduino GUI which is causing the problem.  I looked into fixing it correctly, but got side tracked with the Kinect stuff.

Give me a few days and I'll make a new release.  Fortunately, I can test with Windows 7 64 bit now .. (although this particular issue spans more than just that version of the OS)

GroG

michael96_27

10 years 1 month ago

Thanks GroG!

BTW, is downloading/installing services errors will be fixed too? I do have an internet connection but some errors show in installing services.

Thanks again,

Michael

GroG

10 years 1 month ago

In reply to by michael96_27

Yes... I'm hammering on it now :)

BTW - change your picture ... Don't be a scared gopher !

GroG

10 years 1 month ago

Just so you know, I've got to move all the options in the Arduino editor - here listed as "editor" to a non-Arduino editor named  at the moment "editor2". 

After this is done, it should be easy to enhance the new "editor2" with functionality like autocompletion...

michael96_27

10 years 1 month ago

Thank You!

Btw, I just want you to let you know that 14.9 worked on win7 32bit. Sadly, it's not my machine. So, my option know is to wait for your update. Thanks Again!

michael.

michael96_27

10 years 1 month ago

Hey GroG,

Any updates in myrobotlab to work on 64bit machines?

Thanks,

Michael

GroG

10 years 1 month ago

In reply to by michael96_27

Still working on it.   Regrettably, a lot of the source code initially put in for the Arduino editor is very "messy" - it will need to be removed or refactored.

I'm curious how you plan to use MRL, could you mind elaborating?  Just so you know, the Arduino part which does not work on 64 bit currently is the graphics editor.  The actual "Arduino Service", which does not have a graphical part runs fine on 64 bit machines.  To use it you would need to use the official Arduino IDE to load a PDE/INO on the Arduino - and then run MRL headless...

michael96_27

10 years 1 month ago

Can you help me in my project? Maybe some tips?

Here's my plan:

 

I do have a fully functional rover controlled by an arduino. It uses bluetooth shield for wireless communication together with some sensors. Currently, I made my personal GUI for my robot created in Visual Basic then I found MRL in the net. At first, I was trying to learn OpenCV but the problem is I don't have much knowledge in programming. So, my option now is to try MRL for Ball/Color and Face Tracking.

Could you help me in my project? For now, I want to try color tracking with my arduino rover. I can setup the camera in a pan/tilt and the rover will follow the color as well. I hope you can help me with this :)

Thanks, Michael

michael96_27

10 years 1 month ago

Hi again Grog,

I would just like to ask again if you can help me in my project. or maybe just give me some tips.

Thanks, 

Michael

GroG

10 years 1 month ago

In reply to by michael96_27

Sure Michael, 
I'd be glad to help.   First thing - change your profile picture, You don't need to be a scared gopher :D (http://myrobotlab.org/user/295/edit)

It looks like you have a great project started.  I assume, the camera mounted on the rover is wireless?  Is this correct?  What is the lag like?  What is the type/model of camera?  What is the format of the video stream?  Do you have a camera on the laptop?  Can you upload a picture of what your project is, so far?  Sometimes a picture is worth 1000 words or more.

I checked the OpenCV service in 14.9 and it's not compatible with windows 64 bit...  I'm working on that now....

The OpenCV & JavaCV parts were recently updated to the latest releases.  In the process - some things broke (of course).  Right now, I've got stuff working again on Windows 7 64 bit with the latest OpenCV - There is some cleanup to do, but it does not look like it's in too bad shape..

Here's a Canny filter...

If your doing color tracking you might want to look over this tutorial in preperation - http://myrobotlab.org/content/opencv-how-isolate-object-hue-saturation-and-value

Here's a HSV filter - Oh my, don't I look scary !

To start with you might want to keep it simple..  
For color tracking you should get a well defined uniform color target in a uncluttered background..

michael96_27

10 years 1 month ago

First, thanks for helping me here :)

Now, for your questions:

"I assume, the camera mounted on the rover is wireless?"

-For now, the camera isn't wireless but i'm planning to buy an ip camera.

"What is the type/model of camera?"

-Type of camera is webcam. Genius iLook 300 is the model.

The pictures will follow soon. :)

So, how will the program look like in MRL? I mean, is it full of programming(typing codes) or icon based programming?

BTW, I have read your tutorial. it's GREAT! I can't wait for the time it will be used for my rover :))

GroG

10 years 1 month ago

In reply to by michael96_27

Python will be the scripting used to control your bot.

Basically, a very short script is needed to start the OpenCV service - add the appropriate filters for HSV tracking, and tell the OpenCV service to publish the tracking point to the Arduino.  Actually, it will publish to a Differential Drive service, which will publish commands to the Arduino.   The differential drive is a general purpose service which can track points.  
 

So is your bot working now?  Is it a differential drive i.e. a motor on each wheel, or does it have some other configuration.  This is where pictures help..

GroG

10 years 1 month ago

Alrighty,
I just tested it on  Windows 7 64 bit... 
The repo is patched up..
And OpenCV & JavaCV have been updated.

You can download this "Bleeding Edge" Version by clicking the "All files in zip" on the build server's distribution page :

here -> http://myrobotlab.dyndns.org:8080/job/myrobotlab/ws/myrobotlab/dist/intermediate.729.20120820.0631/

  • unzip it
  • scroll down to OpenCV under the Runtime/Borg tab
  • right-click - "install"
  • wait a while - OpenCV has a lot of dependencies
  • make sure it installs with a success
  • scroll down to OpenCV under the Runtime/Borg tab - (again)
  • right-click - "start" -  name your service, something creative like "camera"  or "opencv"
  • go to the new tab
  • make sure the input drop down is set to OpenCV - (this is the opencv frame grabber, good for most webcams)
  • press "capture"
  • if it works take a screen capture and post it !
  • if it doesn't work send me the myrobotlab.log file from the same directory.

Going forward:
For things which don't work - please attach the myrobotlab.log file and try to provide as much information as possible. Answer my previous question : "So is your bot working now?  Is it a differential drive i.e. a motor on each wheel, or does it have some other configuration.  This is where pictures help.."

michael96_27

10 years 1 month ago

Hi Grog!

I will update you on my progress by Saturday. Our exams are on going and I need to review XD.

I promise to answer all your questions and post pics of MRL running on my system.

 

PS: Is arduino service is now working in MRL on 64bit?. I didn't test it yet XD

 

Thanks, 

Michael

michael96_27

10 years 1 month ago

When I tried to install OpenCV Service from MRL, I assume it's downloading. But it took minutes, hours..... still it's not yet done. The problem can't be my internet because it is consistent and fast. Here's some pic.

BTW, how to attach files here? XD

That seems correct.

The OpenCV binaries are at least 48 Megs... so yes, it would take a while.
You can attach a file to your original forum post, by editing it then scrolling to the end to "file attachments" - send the myrobotlab.log if it did not complete sucessfully.

michael96_27

10 years 1 month ago

I tried installing again OpenCV service but with no luck again. I tried installing it again and left my laptop open since last night. Is it normal for downloading this service? :|

 

BTW, this is my robot for now.(I didn't included pan and tilt platform.. And sorry for the low quality XD. I've taken it from a webcam.)

Looks great.  

No, it shouldn't take that long.  You don't go through a proxy server do you? What kind of connection do you have? Were you going to attach the myrobotlab.log to this post?

michael96_27

10 years 1 month ago

No. I don't go through a proxy server. I am using internet from wifi connected to a DSL connection.

I've attached the log file. It's in .zip format cause .log files are not supported. :))

michael96_27

10 years 1 month ago

I've donwloaded intermediate.737 release and tried again installing OpenCV service - with no luck again.

I've attached another log file("latest log file") in my post. Maybe the problem is in my system somehow isn't it?. However, I will try to donwload it in other system/laptop. :)

Thanks for the log file...  

The first thing I've noticed is your running Java 7 (which has not been tested), I also have noticed that there should be more logging around the download...  I'll download Java 7 and start looking for the issue.

I've downloaded  Java 1.7.6 - and it still works on my system... :P

I'm looking at the logs in detail now..

Your system appears to download all the other dependencies - but it seems to be getting stuck when it hits the dlls...

Perhaps virus checking software which doesn't allow .dlls to be downloaded ?

GroG

10 years 1 month ago

Here's your log snippet :

 

98712 [BORG 3675] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] com.googlecode.javacv#javacv;0.2!javacv-windows-x86_64.jar (28287ms)
98712 [BORG 3675] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] com.googlecode.javacv#javacv;0.2!javacv.jar (16844ms)
98712 [gui] DEBUG org.myrobotlab.framework.Inbox  - gui.msgBox -1 = 0
98712 [BORG 3675] INFO  class org.myrobotlab.framework.ServiceInfo  - Ivy2.run -cache .ivy -retrieve libraries/[type]/[artifact].[ext] -settings ivychain.xml -dependency net.sourceforge.opencv opencv latest.integration -confs runtime,x86.64.windows 
98713 [BORG 3675] DEBUG org.myrobotlab.framework.Outbox  -  msgBox size 1 msg [resolveBegin(String)]
98713 [BORG 3675_outbox_0] DEBUG org.myrobotlab.framework.Outbox  - removed from msgBox size now 0
98713 [BORG 3675_outbox_0] DEBUG class org.myrobotlab.net.CommunicationManager  - sending local
98713 [BORG 3675_outbox_0] DEBUG org.myrobotlab.framework.Inbox  - gui.msgBox +1 = 1
98713 [gui] DEBUG org.myrobotlab.framework.Outbox  -  msgBox size 1 msg [resolveSuccess(String)]
98713 [gui] DEBUG org.myrobotlab.framework.Inbox  - gui.msgBox -1 = 0
98713 [gui_outbox_0] DEBUG org.myrobotlab.framework.Outbox  - removed from msgBox size now 0
98714 [gui_outbox_0] DEBUG org.myrobotlab.framework.Outbox  - /resolveSuccess#String notifyList is empty
98715 [gui] DEBUG org.myrobotlab.framework.Outbox  -  msgBox size 1 msg [resolveBegin(String)]
98715 [gui_outbox_0] DEBUG org.myrobotlab.framework.Outbox  - removed from msgBox size now 0
98715 [gui_outbox_0] DEBUG org.myrobotlab.framework.Outbox  - /resolveBegin#String notifyList is empty
460349 [AWT-EventQueue-0] DEBUG class org.myrobotlab.framework.ServiceInfo  - inspecting org.myrobotlab.service.IPCamera for unfulfilled dependencies
460349 [AWT-EventQueue-0] DEBUG class org.myrobotlab.framework.ServiceInfo  - org.apache.log4j can not be found in current thirdPartyLibs
460349 [AWT-EventQueue-0] DEBUG class org.myrobotlab.framework.ServiceInfo  - hasUnfulfilledDependencies exit true
 
Here's mine :
33323 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] com.googlecode.javacv#javacv;0.2!javacv.jar (3677ms)
33323 [BORG 27916_outbox_0] DEBUG org.myrobotlab.framework.Inbox  - gui.msgBox +1 = 1
33323 [gui] DEBUG org.myrobotlab.framework.Inbox  - gui.msgBox -1 = 0
33323 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - Ivy2.run -cache .ivy -retrieve libraries/[type]/[artifact].[ext] -settings ivychain.xml -dependency net.sourceforge.opencv opencv latest.integration -confs runtime,x86.64.windows 
33323 [BORG 27916] DEBUG org.myrobotlab.framework.Outbox  -  msgBox size 1 msg [resolveBegin(String)]
33323 [BORG 27916_outbox_0] DEBUG org.myrobotlab.framework.Outbox  - removed from msgBox size now 0
33323 [BORG 27916_outbox_0] DEBUG class org.myrobotlab.net.CommunicationManager  - sending local
33324 [BORG 27916_outbox_0] DEBUG org.myrobotlab.framework.Inbox  - gui.msgBox +1 = 1

33324 [gui] DEBUG org.myrobotlab.framework.Outbox  -  msgBox size 1 msg [resolveSuccess(String)]33324 [gui] DEBUG org.myrobotlab.framework.Outbox  -  msgBox size 1 msg [resolveSuccess(String)]

33324 [gui] DEBUG org.myrobotlab.framework.Inbox  - gui.msgBox -1 = 0
33324 [gui_outbox_0] DEBUG org.myrobotlab.framework.Outbox  - removed from msgBox size now 0
33324 [gui_outbox_0] DEBUG org.myrobotlab.framework.Outbox  - /resolveSuccess#String notifyList is empty
33325 [gui] DEBUG org.myrobotlab.framework.Outbox  -  msgBox size 1 msg [resolveBegin(String)]
33326 [gui_outbox_0] DEBUG org.myrobotlab.framework.Outbox  - removed from msgBox size now 0
33326 [gui_outbox_0] DEBUG org.myrobotlab.framework.Outbox  - /resolveBegin#String notifyList is empty
116726 [BORG 27916] INFO  org.myrobotlab.framework.Ivy2  - ivy.retrieve returned 18
116726 [BORG 27916] DEBUG org.myrobotlab.framework.Outbox  -  msgBox size 1 msg [resolveSuccess(String)]
116726 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] net.sourceforge.opencv#opencv;2.4.2!x86.64.windows/opencv_ts242.dll(native) (3172ms)
116727 [BORG 27916_outbox_0] DEBUG org.myrobotlab.framework.Outbox  - removed from msgBox size now 0
116727 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] net.sourceforge.opencv#opencv;2.4.2!x86.64.windows/opencv_gpu242.dll(native) (1698ms)
116727 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] net.sourceforge.opencv#opencv;2.4.2!x86.64.windows/opencv_imgproc242.dll(native) (6427ms)
116727 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] net.sourceforge.opencv#opencv;2.4.2!x86.64.windows/opencv_ml242.dll(native) (2130ms)
116727 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] net.sourceforge.opencv#opencv;2.4.2!x86.64.windows/opencv_core242.dll(native) (7880ms)
116727 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] net.sourceforge.opencv#opencv;2.4.2!x86.64.windows/opencv_objdetect242.dll(native) (2790ms)
116727 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] net.sourceforge.opencv#opencv;2.4.2!x86.64.windows/opencv_photo242.dll(native) (925ms)
116727 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] net.sourceforge.opencv#opencv;2.4.2!x86.64.windows/opencv_flann242.dll(native) (2075ms)
116727 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] net.sourceforge.opencv#opencv;2.4.2!x86.64.windows/opencv_highgui242.dll(native) (4251ms)
116727 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] net.sourceforge.opencv#opencv;2.4.2!x86.64.windows/opencv_calib3d242.dll(native) (3277ms)
116727 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] net.sourceforge.opencv#opencv;2.4.2!x86.64.windows/opencv_legacy242.dll(native) (4982ms)
116727 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] net.sourceforge.opencv#opencv;2.4.2!x86.64.windows/tbb.dll(native) (920ms)
116727 [BORG 27916_outbox_0] DEBUG class org.myrobotlab.net.CommunicationManager  - sending local
116727 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] net.sourceforge.opencv#opencv;2.4.2!x86.64.windows/opencv_video242.dll(native) (1287ms)
116727 [BORG 27916_outbox_0] DEBUG org.myrobotlab.framework.Inbox  - gui.msgBox +1 = 1
116727 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] net.sourceforge.opencv#opencv;2.4.2!x86.64.windows/opencv_stitching242.dll(native) (3804ms)
116727 [gui] DEBUG org.myrobotlab.framework.Inbox  - gui.msgBox -1 = 0
116727 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] net.sourceforge.opencv#opencv;2.4.2!x86.64.windows/opencv_videostab242.dll(native) (2246ms)
116727 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] net.sourceforge.opencv#opencv;2.4.2!x86.64.windows/opencv_nonfree242.dll(native) (1283ms)
116727 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] net.sourceforge.opencv#opencv;2.4.2!x86.64.windows/opencv_contrib242.dll(native) (4037ms)
116727 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - [SUCCESSFUL ] net.sourceforge.opencv#opencv;2.4.2!x86.64.windows/opencv_ffmpeg242_64.dll(native) (29045ms)
116728 [BORG 27916] INFO  class org.myrobotlab.framework.ServiceInfo  - Ivy2.run -cache .ivy -retrieve libraries/[type]/[artifact].[ext] -settings ivychain.xml -dependency com.sun.jna jna latest.integration -confs runtime,x86.64.windows 
116728 [BORG 27916] DEBUG org.myrobotlab.framework.Outbox  -  msgBox size 1 msg [resolveBegin(String)]
116729 [gui] DEBUG org.myrobotlab.framework.Outbox  -  msgBox size 1 msg [resolveSuccess(String)]
116729 [gui_outbox_0] DEBUG org.myrobotlab.framework.Outbox  - removed from msgBox size now 0
116729 [gui_outbox_0] DEBUG org.myrobotlab.framework.Outbox  - /resolveSuccess#String notifyList is empty
116729 [BORG 27916_outbox_0] DEBUG org.myrobotlab.framework.Outbox  - removed from msgBox size now 0
116729 [BORG 27916_outbox_0] DEBUG class org.myrobotlab.net.CommunicationManager  - sending local
116729 [BORG 27916_outbox_0] DEBUG org.myrobotlab.framework.Inbox  - gui.msgBox +1 = 1

Notice you can successfully download .jar files but not .dll

michael96_27

10 years 1 month ago

No, there isn't a popup or warning come from the AVG. However, I've successfully downloaded a dll.

Is there a way on how can I manually install these dlls?

 

BTW, Thank you very much for your help. And, sorry to disturb you XD

It's possible, but a bit of a pain - that is why its done "automatically"
 

There's a couple of possible workarounds - 

1. temporarily turn off the virus checking software

2. download the .dlls manually 

The problems with #2 is - it will not update the local Ivy files - which means MRL will not understand that all the OpenCV dependencies are available, and you will not be able to start the service graphically.  However, if you choose to go with #2 - you will need to make the following sub-directories under your
unzipped - intermediate.737.20120823.0406 directory

libraries\native\x86.64.windows

This is what it looks like on my system...

michael96_27

10 years 1 month ago

I'll try to turn off my firewall and try again to install openCV service. Hope it works(crossed fingers XD) If this doesn't resolve the problem i'll try it manually. How can I start OpenCV?

If you get it downloaded automatically - it's trivial - right click - start  ... (you just have to name it something)

If you install manually - you'll need to use the Jython service

Copy - paste the following in the Jython IDE & hit execute (the button with the gear), when the dlls are in place...

--------------------------------

 

from java.lang import String
from java.lang import Class
from org.myrobotlab.service import Runtime
from org.myrobotlab.service import OpenCV
from com.googlecode.javacv.cpp.opencv_core import CvPoint;
from org.myrobotlab.service import OpenCV
 
# create or get a handle to an OpenCV service
opencv = Runtime.create("opencv","OpenCV")
opencv.startService()
# reduce the size - face tracking doesn't need much detail
# the smaller the faster
opencv.addFilter("PyramidDown1", "PyramidDown")
------------------------------------------------------------------

michael96_27

10 years 1 month ago

It FINALLY WORKED! Here's the pic. I tried shutting down my firewall and it worked XD. Truly, it's the virus checking software s the problem

michael96_27

10 years 1 month ago

Here's a screenshot of me XD

--It's dark there but I will BUY a new webcam cause' it's just only the webcam from the laptop.

GroG

10 years 1 month ago

You can't set format directly on the camera - there is a format parameter which can be set through Python - but some models & makes of cameras ignore it anyway.

You can resize the stream by using the PyramidDown PyramidUp to halve or double (respectively) the stream.

michael96_27

10 years 1 month ago

I've got OpenCV service running, purchased a new webcam, and made a pan and tilt with servos for the camera. What should be the next step :) For this project I want color tracking first :))

 

BTW, What's the joystick service? Can it be used to control arduino robots?

Alrighty,

Let's color track something

1. Make your experiment simple at first.  Find a clear and non-cluttered area to setup your system.  Have a monotone wall or floor in the background.

2. Run through the HSV tutorial with a colored object.

3. When your satisfied with the values you got from the GUI - let me know them - the next step would be making a small & simple Jython with OpenCV and the HSV values your interested in.  This makes startup much quicker

Going forward you can use the script to start and configure all services quickly, including starting the camera capture, loading the approriate filter, etc.  After the service start up and begin tracking, the OpenCV service will be configured to publish a tracking "point" - you'll send this point to a Tracking Service of a PID Service - The point of this middle service is to re-translate the OpenCV graphical 2D point into correction values sent to the Arduino & Servos..

Clear as mud?

michael96_27

10 years 1 month ago

Alrighty, I am working on it now. I'll post pictures as soon as I'm satisfied with the values. :)

michael96_27

10 years 1 month ago

GroG here's the pic :

BTW, Can I use the joystick service to control robots?

GroG

10 years 1 month ago

In reply to by michael96_27

Excellent work Michael !

Very nice - now send me the values that you set up for the InRange filter.

Nice work !  Seems like you caught on quickly...

As for the Joystick - yes, its just another input device - its coordinates would need to be remapped in a service such that they are translated to command sent to the Arduino, Motors, or Servos - but most definately ..  the Joystick service can be used to control robots.  Do you have a joystick or PS2/3 controller?

I usually make them an "override" to autonomous bots, such that if I don't like what the bot is doing autonomously, then I take control with the joystick, or keyboard...

send me the InRange values and I'll send you a starter Jython script... 

BTW - thanks for uploading pictures, I like visualizations - but if you could just right-click - image properties - width = 600 (height should auto-adjust) - that way it doesn't blow out the comment format..  Thanks.. :)

michael96_27

10 years 1 month ago

Here are the value in InRange filter:

 

hue: 3, 33

saturation: 87, 256

value: 230, 256

GroG

10 years 1 month ago

Alrighty.....
The "next step" - is to begin incorporating what you want into a script - I created this one so that you can get an idea of the possibilities.

You will need the latest bleeding edge build - since there was some filter stuff I had to fix. Additionally, there is probably a memory leak in FindContours, or the Jython console logging - I'll figure that out later, since my current focus is fixing up the Arduino service

from java.lang import String
from java.lang import Class
from org.myrobotlab.service import Runtime
from org.myrobotlab.service import OpenCV
from com.googlecode.javacv.cpp.opencv_core import CvPoint;
from org.myrobotlab.service import OpenCV

# create or get a handle to an OpenCV service
opencv = Runtime.createAndStart("opencv","OpenCV")

# add the desired filters
opencv.addFilter("PyramidDown1", "PyramidDown")
opencv.addFilter("InRange1", "InRange")
opencv.addFilter("Dilate1", "Dilate")
opencv.addFilter("FindContours1", "FindContours")

# change values of the InRange filter
opencv.setFilterCFG("InRange1","hueMin", "3")
opencv.setFilterCFG("InRange1","hueMax", "33")
opencv.setFilterCFG("InRange1","saturationMin", "87")
opencv.setFilterCFG("InRange1","saturationMax", "256")
opencv.setFilterCFG("InRange1","valueMin", "230")
opencv.setFilterCFG("InRange1","valueMax", "256")
opencv.setFilterCFG("InRange1","useHue", True)
opencv.setFilterCFG("InRange1","useSaturation", True)
opencv.setFilterCFG("InRange1","useValue", True)

# change value of the FindContours filter
# opencv.setFilterCFG("FindContours1","minArea", "150")
# opencv.setFilterCFG("FindContours1","maxArea", "-1")
# opencv.setFilterCFG("FindContours1","useMinArea", True)
# opencv.setFilterCFG("FindContours1","useMaxArea", false)

# ----------------------------------
# input
# ----------------------------------
# the "input" method is where Messages are sent to this Service
# from other Services. The data from these messages can
# be accessed on based on these rules:
# Details of a Message structure can be found here
# http://myrobotlab.org/doc/org/myrobotlab/framework/Message.html 
# When a message comes in - the input function will be called
# the name of the message will be msg_++_+
# In this particular case when the service named "opencv" finds a face it will publish
# a CvPoint.  The CvPoint can be access by msg_opencv_publish.data[0]
def input():
    #print 'found face at (x,y) ', msg_opencv_publish.data[0].x(), msg_opencv_publish.data[0].y()
    arrayOfPolygons = msg_opencv_publish.data[0]
    print arrayOfPolygons
    if (arrayOfPolygons.size() > 0):
   	print arrayOfPolygons.get(0).centeroid.x(),arrayOfPolygons.get(0).centeroid.y()
    return object

# create a message route from opencv to jython so we can see the coordinate locations
opencv.addListener("publish", jython.name, "input", CvPoint().getClass()); 

# set the input source to the first camera
opencv.capture()

What this script does :

  • it creates and starts the an OpenCV service
  • it adds the appropriate filters
  • it configures the filters
  • it sets a message route from the OpenCV service to the Jython service for "found polygons"
  • for any found polygon, the Jython service prints out the first polygons center coordinates

Here is what happens on my laptop. 
You'll noticed the 4 filters are not displayed, this is because the service is not notifying the gui that new filters have been added, although, they were added programmatically.  At the moment, if you add a filter programmatically, you'll have to remove it programmatically.  Some gui notification details are low on my priority list.  So, whatever filter values you have assigned, I had something which fit the criteria,.Strangely, I think it was my hair :D 

It found 1 polygon and sent it back to the jython service.

So the polygon's center is printed out in the jython service's "jython console".
here you can see the x,y location of that polygon at (228,87)

Now, the Jython service could take those two values, adjust or modify them, and send them to an Arduino service which has 2 Servo's attached ....   and viola !  you have color tracking :)

Hope this makes sense.

BTW - this is getting very off topic, if you wouldn't mind could you create another forum entry if you have another question or preferrably create a page and post your Robot Project !  For an example look at DancesWithRobots' Houston entry - http://myrobotlab.org/content/houston

GroG

10 years 1 month ago

Disregard the 

"</sending></sending>" tags at the end of the script... This is being added by Drupal for some incorrect reason...

michael96_27

10 years 1 month ago

The coordinates (288,87) can be mapped/adjusted to fit servos' angle isn't it? :D

And in the script:

 

opencv.setFilterCFG("InRange1","hueMin", "3")
opencv.setFilterCFG("InRange1","hueMax", "33")
opencv.setFilterCFG("InRange1","saturationMin", "87")
opencv.setFilterCFG("InRange1","saturationMax", "256")
opencv.setFilterCFG("InRange1","valueMin", "230")
opencv.setFilterCFG("InRange1","valueMax", "256")
opencv.setFilterCFG("InRange1","useHue", True)
opencv.setFilterCFG("InRange1","useSaturation", True)
opencv.setFilterCFG("InRange1","useValue", True)

Can I edit the values so can I choose other colors? Am I correct? :))

The (x,y) represents the pixel location of the center of the polygon found, yes it can be re-mapped to servo angle.

Yes, you can change color by changing the filter configuration values...

If you get the Sphinx service to working, with a bit more logic added to the script, you could get it to recognize the word "red" and set the filter configuration to appropriate "red" settings, or have it recognize the word "blue" and set the appropriate "blue" filter settings, etc....

 

michael96_27

10 years 1 month ago

The jython console is not printing x,y coordinates, Why is that? Do I need to download/install jython service? cause it's says "not installed" in the menu but it's in the tab. :)