Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
(API) Cam2D_Snapshot returns wrong size image
#1
The attached code consistently writes a 100x75 image instead of the expected 640x480.  In the code I was writing when I discovered the bug, it sometimes returns the correct size and sometimes the wrong size, so it looks like a race condition.  The tiny incorrect size also looks suspiciously similar to the size of the thumbnail I see in the camera preview window.

Relevant code is this:

virtual_camera = RDK.Cam2D_Add(item_object=station, cam_params="FOCAL_LENGTH=1.93 FOV=65.5 SIZE=640x480")

filename = "/tmp/bug.png"
RDK.Cam2D_Snapshot(file_save_img=filename)

I'm on Ubuntu 22.04, RoboDK v5.4.1 (64 bit)

Full code:


Code:
#!/usr/bin/python3

from robolink import *    # API to communicate with RoboDK
from robodk import *      # robodk robotics toolbox

RDK = Robolink()

def clear_station(rdk):
    station_name = "Camera bug"

    # If there was already a station for this script, delete it
    station = rdk.Item(station_name)
    try:
        station.Delete()
    except robolink.InputError as e:
        pass

    station = rdk.AddStation(station_name)
    return station

station = clear_station(RDK)
virtual_camera = RDK.Cam2D_Add(item_object=station, cam_params="FOCAL_LENGTH=1.93 FOV=65.5 SIZE=640x480")

filename = "/tmp/bug.png"
RDK.Cam2D_Snapshot(file_save_img=filename)

While we're on the topic, are all the misspelled "LENGHT"s in the API docs (eg., "FOCAL_LENGHT" instead of "FOCAL_LENGTH") for the camera setup string what we should actually use, or is the library actually expecting the correct spelling?


Attached Files Image(s)
   
#2
Hi,

In order for the snapshot to work, the preview window must be opened --and it takes some time to do so.
Adding a pause(0.1) after Cam2D_Add should fix your issue.

You can use the correct or the misspelled spelling. I'll update the documentation with the correct spelling.
Thank you for pointing that out.
Find useful information about RoboDK and its features by visiting our Online Documentation and by watching tutorials on our YouTube Channel.
#3
Thanks for the quick reply. I added a 3 second time.sleep(3) after Cam2D_Add() and it still consistently produces a tiny image. The snapshot window also stays small. Maybe it's something about gnome not accepting a size hint? But isn't the SNAPSHOT parameter supposed to make the saved image size independent of the preview window? Setting that to 640x480 doesn't help either.
  




Users browsing this thread:
1 Guest(s)