Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Camera does not work in NOUI mode

#1
I am working on a project where I start RoboDK through the python API with the NOUI flag.
If I now want to take a snapshot with a camera, I first run the following code:



Code:
camera.setParam('Open', 1)


since the documentation seems to indicate that this is necessary (and I don't get a correct snapshot if I leave this out). But, if you run RoboDK in NOUI mode, this call hangs and nothing happens.

In terms of debug prints, a successful call when NOUI is not passed looks like this:



Code:
Setting item parameter:  "Open" = "1"
Adding new docked window:  "Camera"
Camera context created successfully
Ready to render new camera context...
Done
Camera parameters updated


while my current output is this (with NOUI):


Code:
Setting item parameter:  "Open" = "1"
Adding new docked window:  "Camera"
Camera context created successfully

Is this intended behavior? Or, should the camera's also work when you run without a UI?
#2
You won't be able to simulate cameras or take snapshots using the NOUI option because RoboDK does not create a 3D environment and it does not use graphics card resources. However, you should be able to simulate cameras or take snapshots when RoboDK is hidden (and you are not using the NOUI option).
#3
Hey Albert,

Thank you for the quick reply.

The hidden option does indeed allow me to run

Code:
camera.setParam('Open', 1)


But, whichever command I run after this raises the following error:


Code:
ConnectionResetError: [Errno 104] Connection reset by peer


So, it seems something still goes wrong while trying to open the camera.
Would you be able to provide further insight?

Thanks in advance,
Bjarne
#4
If you want to take screenshots of the camera you can taking snapshots directly, without trying to open/close the camera window.

If you want to open the Camera window it may be better if you show the main RoboDK window first.
#5
Hi Albert,

When I remove the open statement and run using `HIDDEN`, the call to Cam2D_Snapshot fails:

Code:
│ ./venv/lib/python3.8/site-packages/robodk/robolink.py:3439 in Cam2D_Snapshot │
│   3436 │   │   │   │   self.COM.settimeout(3600)                           |
│   3437 │   │   │   │   if len(file_save_img) == 0:                           │
│   3438 │   │   │   │   │   # If the file name is empty we are expecting a by │
│ ❱ 3439 │   │   │   │   │   success = self._rec_bytes()                       │
│   3440 │   │   │   │   else:                                                 │
│   3441 │   │   │   │   │   success = self._rec_int()                         │
│   3442 │   │   │   │   self.COM.settimeout(self.TIMEOUT)                     │
│                                                                              │
│ ./venv/lib/python3.8/site-packages/robodk/robolink.py:871 in _rec_bytes |
│                                                                              │
│    868 │   def _rec_bytes(self):                                             │
│    869 │   │   """Receives a byte array"""                                   │
│    870 │   │   buffer = self.COM.recv(4)                                     │
│ ❱  871 │   │   bytes_len = struct.unpack('>I', buffer)[0]  #q=unsigned long  │
│    872 │   │   bytes_list = []  # this method is significantly faster than a │
│    873 │   │   bytes_count = 0                                               │
│    874 │   │   bytes_remaining = bytes_len                                   │
╰──────────────────────────────────────────────────────────────────────────────╯
error: unpack requires a buffer of 4 bytes

Process finished with exit code 1

If I remove the open statement and allow RoboDK to be shown, I receive an image of size 0 from the Cam2D_Snapshot call.

Could you maybe provide some minimal code showing how you could obtain the snapshot without RoboDK being visible? (I don't really want to open the camera. The only reason I have been doing this, is because otherwise the image does not come out right. If you know other ways of obtaining a valid snapshot, that's also fine.)

Kind regards,
Bjarne
  




Users browsing this thread:
1 Guest(s)