Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-camera with RSUSB - Follow-up #6467

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions examples/multicam/rs-multicam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@ int main(int argc, char * argv[]) try

std::vector<rs2::pipeline> pipelines;

// Start a streaming pipe per each connected device
// Capture serial numbers before opening streaming
std::vector<std::string> serials;
for (auto&& dev : ctx.query_devices())
serials.push_back(dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER));

// Start a streaming pipe per each connected device
for (auto&& serial : serials)
{
rs2::pipeline pipe(ctx);
rs2::config cfg;
cfg.enable_device(dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER));
cfg.enable_device(serial);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dorodnic, it would make this a much simpler change everywhere this change is needed to allow enable_device() to accept a rs2::device as well as a serial number string. After all, we have dev here and the rs2::config just wants a device. Doing the lookup again seems wasteful. It would be a bigger change to add support for this, but it would make it usage for users much cleaner going forward.

    for (auto&& dev : ctx.query_devices())
       cfg.enable_device(dev);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @radfordi
You are 100% right. I didn't want to expand the scope of this PR beyond simply getting your original work merged, but I also thought about it.

pipe.start(cfg);
pipelines.emplace_back(pipe);
// Map from each device's serial number to a different colorizer
colorizers[dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER)] = rs2::colorizer();
colorizers[serial] = rs2::colorizer();
}

// We'll keep track of the last frame of each stream available to make the presentation persistent
Expand Down
34 changes: 25 additions & 9 deletions src/device_hub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ namespace librealsense
{
bool filtered = false;
auto data = dev->get_device_data();
for (const auto& usb : data.usb_devices)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So TM2 was just skipped... It is weird that the usb screening was not in place and yet it worked

{
if (usb.vid == vid || vid == 0)
{
result.push_back(dev);
filtered = true;
break;
}
}
for (const auto& uvc : data.uvc_devices)
{
if (uvc.vid == vid || vid == 0)
Expand Down Expand Up @@ -71,21 +80,28 @@ namespace librealsense
{
// _camera_index is the curr device that the hub will expose
auto d = _device_list[ (_camera_index + i) % _device_list.size()];
auto dev = d->create_device(_register_device_notifications);

if(serial.size() > 0 )
try
{
auto new_serial = dev->get_info(RS2_CAMERA_INFO_SERIAL_NUMBER);
auto dev = d->create_device(_register_device_notifications);

if(serial.size() > 0 )
{
auto new_serial = dev->get_info(RS2_CAMERA_INFO_SERIAL_NUMBER);

if(serial == new_serial)
if(serial == new_serial)
{
res = dev;
cycle_devices = false; // Requesting a device by its serial shall not invoke internal cycling
}
}
else // Use the first selected if "any device" pattern was used
{
res = dev;
cycle_devices = false; // Requesting a device by its serial shall not invoke internal cycling
}
}
else // Use the first selected if "any device" pattern was used
}
catch (const std::exception& ex)
{
res = dev;
LOG(WARNING) << "Could not open device " << ex.what();
}
}

Expand Down