OpenMV IDE, change camera name

Hello, I’m using multiple cameras with OpenMV IDE. Sometimes the ttyACM* devices are swapped between the cameras, so i put a udev rule to create stable symlinks.
It works and I can see the stable links, but unfortunately OpenMV does not detect my symlinks, only the original ttyACM devices which are randomly assigned.
With udev it is not possible to rename the devices, it’s only possible to create links to them, AFAIK.
Is it possible to force a specific name to OpenMV’s connect camera?

Is there some other way to cope with multiple cameras?

Regards

The IDE just scans the whatever list of ports the operating system returns. This is from a library call function that returns the list.

The IDE does remember the last port you used… so, as long as the port name doesn’t change this should be workable… but, cumbersome.

You can also use the Open Terminal feature under tools->Open terminal to create custom named connections to the REPL prompt to cameras. You can print images in this mode by adding print(img.compressed_for_ide()) to your code. It’s a little bit less nice than the main debug connection but works.

Thanks for the reply. Unfortunately it only shows the real ttyACM devices and not any link to them.
Port names changes quite often and it is dangerous too, because the risk of changing setup to the wrong camera is high.
Best solution would be a command line option like -c “camera_name”.
I had a look at the source code, didn’t find the lines where the device is chosen, don’t have any clue about QT,

Regards

Alberto

It’s right here: qt-creator/openmvplugin.cpp at d128254d7f1fe1dc076c6efe0a6e9a5b1e52b1ef · openmv/qt-creator · GitHub

As you can see. I just call a library function and then filter the list of ports returned.

If there are multiple ports then I give you a prompt here:

Thank you.
Unfortunately it seems that it is not just a matter of selecting a different file name. Even after doing this QSerial refuses to use it.
Can’t think of any reason for this, but it’s like that from 2013:

So I added a command line argument for the camera USB serial number.

If the argument is not used everything is as before.
When an argument is passed, only that camera is shown.
Then it is easy to have several launchers ttyACM safe.

Not really nice, but is the best I could do.
It could be helpful to me and other if you could add this feature to the main code base. Even better would be to rewrite this part with a Posix compliant library, but I understand it is a big task.

This is what I did, tested only on Linux:

/* Alberto Garlassi 14-04-21
*

  • Added USB camera filtering based on serial number identifier.

  • It is passed as a command line argument and allows to deploy several launchers

  • each one controlling a predefined camera.

  • This is because QTSerial can’t use symlinks to devices

  • see QSerialPort and port naming on Linux (Centos) | Qt Forum

  • and relies on the native device names, wich can change after USB disconnect.

  • Udev rules can’t rename the devices, can only create stable symlinks to them.

  • USB serial identifier:
    /bin/udevadm info --name=/dev/ttyACM0 | grep SERIAL_SHORT

  • Tested on Ubuntu 2004.
    */

    foreach(QSerialPortInfo port, QSerialPortInfo::availablePorts())
    {
    if((port.hasVendorIdentifier() && ((port.vendorIdentifier() == OPENMVCAM_VID) || (port.vendorIdentifier() == ARDUINOCAM_VID))
    && port.hasProductIdentifier() && ((port.productIdentifier() == OPENMVCAM_PID) || ((port.productIdentifier() & ARDUINOCAM_PID_MASK) == ARDUINOCAM_PID)))
    && (port.serialNumber() == camera_serial || camera_serial == QStringLiteral(“NO_USB_SERIAL_FILTER”)))
    {
    stringList.append(port.portName());
    }
    }

Regards

Alberto Garlassi

Can you send a PR to the IDE? I can review it then and merge the code change for everyone to benefit from.

Of course, but the command line argument parsing part needs to be rewritten, I didn’t succed in adding a new option and ended with modifying another parameter I don’t use.
I don’t have time for that, please have a look at it.

Okay, can you do this? Please make an issue on the openmv ide GitHub and add a link to this forum post.

Pull request done.
Did more operational tests with five cameras and everything is OK.

Regards