Webcam not working under opencv

Hi,

Another newby to robotics having an issue.. Got my uno clone and 2 servos connected and webcam connected to laptop and tryin to operate the tracking script but servos only respond if I move my mouse veeerry slowly and very jittery.

My webcam works under manycam but does not show up in opencv on myrobotlab.

I have my right hand printed for my inmoov robot and servo bed made, bought 12 servos and uno but cannot get this to work. I have been working on this for days and am growing disheartened.

I can operate the servo with another script to 45 degrees and 90 degrees etc so I know the uno and servos are ok.

GroG's picture

Hello and Welcome Gregted

As a good book once said "DON'T PANIC" ...  and no reason to feel disheartened, we'll figure it out.

First thing first - start MRL - run the script - and when it "no-worky" send me a no-worky log file - http://myrobotlab.org/content/helpful-myrobotlab-tips-and-tricks#noworky

The slooowww servo response sounds very strange - If you don't run the script do the servo's run fine - for example if you just create an Arduino service and a Servo service and attach them does it work as you would expect ?

Unfortunately, not all webcams work with OpenCV - send the log file and it will help me understand your setup.

And change your Avatar - you are no longer a scared gopher !

GroG's picture

There is a syntax error in

There is a syntax error in the script, probably because there is an extra space in the very beginning.  Python is EXTREMELY picky about indentation.

Here's the error :

192120 [Thread-13] ERROR org.myrobotlab.logging.Logging  - ------
SyntaxError: ("mismatched input '     ' expecting EOF", ('<string>', 1, 5, '     tracker = Runtime.createAndStart("tracker","Tracking")\n'))
 
Try removing the spaces at the very beginning.
 
If all installed correctly there should be an exectuable called lkdemo.exe in the following directory for your machine.
 
C:/myrobotlab/myrobotlab.1076M.20130309.1113/libraries/native/x86.32.windows/lkdemo.exe

cd to that directory and try to run lkdemo.exe

What sometimes happens is your system is missing MSVCRT10.dll 

And here is a link to the MSVCRT 2010 redistributables - 

http://www.microsoft.com/en-us/download/details.aspx?id=5555

This was the problem with Cix's system.

Also, please post updates to your issue on the forum post, not the shoutbox.  Anything we learn and report in the shoutbox is very transitory - but the forum post might help someone else with the same problem.

 

Gregted's picture

servos ok but still no camera

Thanks for the reply Grog.

I have downloaded that file and have control over servos but still no camera.

I have tried 2 so far and they work on other programs. Do I have to install some other driver or do I have to have the camera runing before I start myrobotlab.

My camera is plugged into a usb port and the lights around the camera are lit so it is working.

What camera do you reccomend.
 

GroG's picture

Making Progress !

Great - glad to hear the Servos are working !

Well let's see if we can get more information on the webcam.

  • make sure nothing else is utilizing the webcam - the webcam definately needs to be not currently used by any other program
  • you say you have a webcam and are running this from your laptop?  Does your laptop have a integrated camera - there might be some confusion regarding which camera is being utilized
  • open a "command prompt"
  • type (or preferrably copy paste the following command )

    cd C:/myrobotlab/myrobotlab.1076M.20130309.1113/libraries/native/x86.32.windows

  • within this directory there should be an executable called lkdemo.exe - run it by typing its name
  • This is an opencv demo - without MRL - it should start a video feed or give an informative error message

Let me know how it goes...

Change your Avatar ! - go to http://myrobotlab.org/user/707/edit 

Halfway down - is "upload picture"  You are not a scared gopher ! :D

Gregted's picture

Tracking problems with camera

Camera now working with issues.

Followed Grogs suggestion and removed all spaces from script Tracker and everything loaded up like a charm.

But....

When I click on a point on the screen, the camera swings up and right and then python script says tracking point missing as it should but why is camera swinging up and away in the first place.

I have just hot glued my webcam to the outside of my Y servo arm and that servo is hot glued to the outer arms of my X servo arm so servo Y is off to the side of center of servo X and then the webcam is off center of servo X.

Do these have to be centered?

If I could post a pic, it would be easier to explain.

GroG's picture

By all means POST A PICK !

By all means POST A PICTURE !

Also if a Picture = 1000 words then video = 30 X 1000 words per second :)

Gregted's picture

Top picture shows total

Top picture shows total setup. Bottom servo is X. Top servo is Y and webcam hot glued to top servo.

I took the clamp from the bottom of the webcam and hot glued it to the back of the bottom servo so I can clamp it onto any surface.

These 2 servos are plugged into a wishboard and then into my freetronics Arduino clone board.

So the problem is when I click on anything in the screen on opencv, a set of coordinates appears briefly and the camera pans up and to the right or left.

What I am thinking is the point on screen is relative to the servo position and not a visual image and if so I need to centre the servos and camera as they pan to this point of interest and then the image is off screen everytime.

Another curious thing is that these old servos work fine but my new Mg995 servos don't work at all.

 

Update.... Working.. You beauty.. I noticed the option of changing the xpid and ypid settings and changed invert to direct and had a ureka moment and had to call the family in to get tracked around the room.

Will post a video on youtube this afternoon. Thanks to all for the help.

BTW. This simple setup works great. Still gives access to the servo screws to reposition the servo arms for center and took longer for the hot glue gun to heat up than to assemble.