1

I'm trying to do some image processing and I have a script written in python that works off the NAO. I need to transfer the code to choreographe so that it can run on the robot.

How do I import opencv for the NAO using python?

Thanks for your help!

Sample code would be really helpful too with using opencv if it is different than using it outside of the NAO

user3452598
  • 11
  • 1
  • 2

5 Answers5

1

I've never tried the opencv import within Choreographe, but I guess that you have to create an empty block (script template) and use import cv.

Anyway, probably you will find performance issues if you try to make the image processing in the robot, try to do it in a different computer using the SDK

Here you can find examples to acquire an image from the robot: https://community.aldebaran-robotics.com/doc/1-14/dev/python/examples/vision/index.html

Manuel
  • 2,236
  • 2
  • 18
  • 28
1

depending of your version:

import cv
or
import cv2

then you could for instance write image using methods like:

cv.saveImage( ...
or
cv2.imWrite(...
Alexandre Mazel
  • 2,462
  • 20
  • 26
  • Both, Choregraphe and the python console on the robot itself, raise an ImportError saying "No module named [cv/cv2]". Firmware 1.14.5. – Gerrit-K Jun 04 '14 at 11:18
1

Since my last answer, I've wrotten a small tutorial to use python and opencv with NAO.

Here it is:

http://www.mangedisque.com/Alma/NaoStuffs/using_python_to_develop_your_vision_algorithm_on_your_robot_-_final.odp

Alexandre Mazel
  • 2,462
  • 20
  • 26
1

This video from the Aldebaran website has some info about using Python/OpenCV/Nao together.

I've never used Choreographe with OpenCV, but when using just plain Python one way to translate the Nao camera's image into one you can process with OpenCV is to use this line:

img = (numpy.reshape(numpy.frombuffer(nao_image[6], dtype = '%iuint8' % nao_image[2]), (nao_image[1], nao_image[0], nao_image[2])))

img is now OpenCV friendly. Hope this helps!

Ellburrito
  • 127
  • 11
1

I just had the same problem and first, you need to install NumPy 1.9 in your machine. (Im using windows 10) Just run the .exe normaly and then, you need download open cv. After that you can watch this video: https://www.youtube.com/watch?v=3xAslL8htuQ it helps me a lot. I think that is gonna help you more than I did Hope you can do it. I also have a NAO robot, good luck haha (sorry for the bad english, is not my native language)

Wanessa
  • 11
  • 1
  • If you post a link, you should describe all important notes and steps of the information that the link provides, because links tend to become invalid and such answers tend to become useless. – Alex M Aug 11 '16 at 15:23