loading
 
Camera Properties not changing
Melissa from United States  [2 posts]
14 year
Hi Steven,
I am having some difficulty with camera properties working with Logitech Webcams (I am not sure their exact model) but they work fine with roborealm as long as I go through options and set them to YUY2. However, I have camera properties set as the first line of my program...shouldn't that set the camera? It isn't I am only getting a black screen with a thin line of noise on the bottom.

It is becoming a problem because I am switching between two and I have to do it manually (by going through options). I am calling the camera switch through python and that works great...its just my second camera is the black screen.

any help would be appreciated!
Anonymous from United Kingdom  [99 posts] 14 year
I have just been working on getting two cameras working in python.  

I create two API instances using:
def Initialize_Vision_API(camera,RR_port_Num):
    global rr,process
    # initialize the API class
    RR_port = '-api_port '+str(RR_port_Num)
    print "opening API"
    try:
        #Changed to match my path
        temp = 'C:\Program Files\RoboRealm\Roborealm.exe '+RR_port
        process = subprocess.Popen(temp)
        time.sleep(0.5)
        print "Camera started successfully"
    except:
        print "No Camera Connected"
        print "Check path in Popen statement to make sure it points to your Roborealm executable"

    rr = RR_API()

    #connect to RoboRealm  Make sure that Roboream is open and Running the API server
    try:
        rr.Connect("localhost",RR_port_Num)  #Connect has been modified to take port #
    except ValueError:
        print "API Server is not running!"
        sys.exit()

Here is the slight mod to Connect:
def Connect(self, hostname,port_num):
    self.sock.connect((hostname, port_num))


Now I also had trouble with the Logitech cameras!  

If I call:
    rr.SetCamera("on")
    rr.SetCamera(camera)  #where camera is a string with the name of the camera in it.

That works SOME of the time.  The Logitech cameras want to load their own driver, which messes with some of the settings. (IE it alwasy seems to drop back to 320x240 and when I check my roborealm instance, the logitech camera is not listed as selected.

However, if I do an initialization by calling:
        camerastring = "<Camera_Properties> \
        <camera>Logitech Quickcam Fusion</camera> \
        <brightness_value>128</brightness_value>\
        <contrast_value>32</contrast_value>\
        <software_auto_exposure>FALSE</software_auto_exposure>\
        <saturation_value>32</saturation_value>\
        <video_rate>25</video_rate>\
        <sharp_value>2</sharp_value>\
        <gamma_value>1</gamma_value>\
        <video_size>640 x 480</video_size>\
        <video_format>YUY2</video_format>\
        <hue_value>64</hue_value>\
        </Camera_Properties><interface> \
        <command>resize</command>\
        <width>700</width>\
        <height>500</height>\
        </interface>"
    try:
        rr.Execute(camerastring)
    except:
        print"Failed to find Camera on Robot!"

It works great!  You need to clear this initialization by executing your new filters as doing the camera initialization seems to take lots of cycles.  You will also want to replace my "Quickcam Fusion" with whatever camera you have.

Hope this helps!
mmason
Anonymous 14 year
Melissa,

Probably the best way to do this is to keep both cameras active and just switch between the two using a software flag. Switching or starting/stopping cameras is the most risky and slowest procedure in Windows. Risky in the sense that if something is going to go wrong with a camera it will be at startup.

So what I would do is config the current camera, switch to the other using the options dialog and config that too. Then use the Marker module to add the second camera in the pipeline such that unclicking the Run button would show one camera view and pressing the Run button would then run the Marker module which would then show the second. Thus both cameras are running but only one is in view at a time. From here you can then just reference the appropriate image.

This makes some big assumptions in that both cameras are always connected to the machine. If not, can you describe a bit more about the reason why you are switching between the two frequently?

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index