IntelRealSense / librealsense

Intel® RealSense™ SDK
https://www.intelrealsense.com/
Apache License 2.0
7.61k stars 4.83k forks source link

Multicam issue with Matlab #3733

Closed marcoagbarreto closed 5 years ago

marcoagbarreto commented 5 years ago

Required Info
Camera Model { SR300 }
Firmware Version {3.21.0.0}
Operating System & Version {Win (10)}
Kernel Version (Linux Only)
Platform {PC}
SDK Version { 2.19.1 }
Language {Matlab R2018a}
Segment {others }

Issue Description

<I'm using a multicam setup for a 3D capturing system with an array of 5 SR300 cameras using Matlab. I'm trying to acquire depth images by turning on 2 cameras at a time, while the others are turned off for the total of 5 cameras. The problem is that while using the realsense.pipeline(), the command automatically selects a realsense camera, and I can't adress to a specific camera. I tried communicating to each camera individually using Matlab with the multicam example https://github.com/IntelRealSense/librealsense/tree/master/examples/multicam , but with no succes at all.

Any help would be appreciated, thanks in advance. >

lramati commented 5 years ago

Can you share your code?

marcoagbarreto commented 5 years ago

Can you share your code?

ctx = realsense.context(); % Create librealsense context for managing devices n_devices = length(ctx.query_devices()); pipelines = realsense.pipeline();

for i = 1:n_devices

pipe = realsense.pipeline(ctx); cfg = realsense.config(); cfg.enable_device(dev.get_info(realsense.camera_info.serial_number)) pipe.start(cfg); pipelines.get_active_profile(pipe)

end

lramati commented 5 years ago

There appears to be some amount of missing code here. Where did dev come from?

marcoagbarreto commented 5 years ago

I was running this code to test the depth camera before trying to manage multicameras. "dev" comes from this code.

% Make Pipeline object to manage streaming
pipe = realsense.pipeline();

% define object for the point cloud
pcl_obj = realsense.pointcloud();

% Start streaming on an arbitrary camera with default settings
profile = pipe.start();

% Get streaming device's name
dev = profile.get_device();
name = dev.get_info(realsense.camera_info.name);

% Obtain frames from the camera
for  i = 1:5
    frames = pipe.wait_for_frames();
end

% Select depth frame depth = frames.get_depth_frame();

% Obtain point cloud
points = pcl_obj.calculate(depth);
vertices = points.get_vertices();

% Convert vertices into point cloud object
ptCloud = pointCloud(vertices);

% Save point cloud into PLY file
pcwrite(ptCloud,'3D_out.ply','PLYFormat','binary');

% Show point cloud
pcshow(ptCloud);
title(sprintf("Depth frame from %s", name));

pipe.stop();
marcoagbarreto commented 5 years ago

Hi, I just figure it out how to adress an specific camera, I went to the SDK and grab all of my cameras serial number and add them to a char array, later on I assigned the serial number to the config file, then made a loop to check the stream in all cameras. Here is the code to loop through all cameras just to check that they are connected. Issue solved. Thanks

ctx = realsense.context(); % Create librealsense context for managing devices n_devices = length(ctx.query_devices()); % Number of devices connected cam_sn = ['627204001255';'627206001644']; % Serial numbers of all cameras

for i = 1:n_devices % Loop through all devices detected

pipe = realsense.pipeline(ctx); % Make Pipeline object to manage streaming cfg = realsense.config(); % Create a new configuration cfg.enable_device(cam_sn(i,:)); % Enable device in config file with the serial number of the camera pipe.start(cfg); %Start streaming on a selected camera with default settings pipe.stop(); % Stop streamming

end