Wanted to take a second a share a weird phenomenon.

Heres is my experience so far on Windows 8.1 32-bit MRL .1324. Based on my previous post, I must set Input Source to "VideoInput" NOT OpenCV. I must set index to "2" (for USB connected Hercules).

I MUST start and stop CAPTURE 3 times with NO luck. The USB camera only blinks a blue light each time. The 4th time I press capture, the camera works.

If I stop capture and start capture again. Nothing happens. I stop and start capture 4 more times with no luck. The 5th time I start capture it works. 

Then if I ust capture again, I must stop and start the capture 5 times with no luck. On the 6th try the capture works.

Some sort of a counter somewhere ??!! This has been driving me crazy. 

Maybe someone can help.

GroG

8 years 6 months ago

Opencv can be a challenge to use sometimes because it's native ... and it requires jni and other complexities.

Perhaps you should state what you want to achieve? Just taking a picture as the title states?

speech = Runtime.createAndStart("Speech","AcapelaSpeech")
speech.setVoice("Sharon")
 
 
from java.lang import String
from org.myrobotlab.service import Sphinx
 
# create ear and mouth
ear = Runtime.createAndStart("ear","Sphinx")
#mouth = Runtime.createAndStart("mouth","Speech")
opencv = Runtime.createAndStart("opencv","OpenCV")
opencv.addFilter("pdown","PyramidDown")
opencv.setDisplayFilter("pdown")
opencv.capture()
# start listening for the words we are interested in
ear.startListening("hello zeno|take a photo")
 
 
# set up a message route from the ear --to--> python method "heard"
ear.addListener("recognized", python.name, "heard"); 
 
def heard(data):
      print "heard ", data
      if (data == "hello zeno"):
         speech.speakBlocking("Hi Bob.") 
      elif (data == "take a photo"):           
           photoFileName = opencv.recordSingleFrame()
           print "name file is" , photoFileName
           speech.speakBlocking("photo taken")
          
           
 
ear.attach("speech")

speech = Runtime.createAndStart("Speech","AcapelaSpeech")
speech.setVoice("Sharon")
 
 
from java.lang import String
from org.myrobotlab.service import Sphinx
 
# create ear and mouth
ear = Runtime.createAndStart("ear","Sphinx")
#mouth = Runtime.createAndStart("mouth","Speech")
opencv = Runtime.createAndStart("opencv","OpenCV")
opencv.setInputSource("VideoInput")
opencv.setCaptureIndex(2)
opencv.addFilter("pdown","PyramidDown")
opencv.setDisplayFilter("pdown")
opencv.capture()
# start listening for the words we are interested in
ear.startListening("hello zeno|take a photo")
 
 
# set up a message route from the ear --to--> python method "heard"
ear.addListener("recognized", python.name, "heard"); 
 
def heard(data):
      print "heard ", data
      if (data == "hello zeno"):
         speech.speakBlocking("Hi Bob.") 
      elif (data == "take a photo"):           
           photoFileName = opencv.recordSingleFrame()
           print "name file is" , photoFileName
           speech.speakBlocking("photo taken")
          
           
 
ear.attach("speech")

Hi 
 
I'm sorry for giving the wrong answer before. It's sometimes difficult to find what some parameters should be set to.
 
I hope this will work better:
 
opencv.setInputSource("camera")
opencv.setCameraIndex(2)
 
/Mats