librealsense icon indicating copy to clipboard operation
librealsense copied to clipboard

Get images from my own computer, instead of RealSense

Open KeCh96 opened this issue 8 years ago • 3 comments

Required Info
Camera Model SR300
Firmware Version
Operating System & Version Ubuntu
Kernel Version (Linux Only) 4.15.0
Platform Linux
SDK Version SDK2

I try to read image by the following code:

pipeline = rs.pipeline()
pipeline.start()
while True:
    frames = pipeline.wait_for_frames()
    depth  = frames.get_depth_frame()
    depth_data = depth.as_frame().get_data()
    np_image = np.asanyarray(depth_data)

I found when I use frames.get_depth_frame(), the realsense camera do not open, instead the camera of my computer opens. Then I get error: RuntimeError: null pointer passed for argument "frame_ref" Similar situation happens when I use frames.get_color_frame(), the realsense camera do not open. Unexpectedly, I get image from my own computer camera. Does anyone know the solution? Thanks in advance. @dorodnic @zivsha @ev-mp

KeCh96 avatar Aug 24 '18 02:08 KeCh96

I don't really know how the SR300 camera behave, but I had a similar issue with a D4XX. I'm guessing that you are not specifying precisely enough which device you want to access, and the first one might then be selected by default (which can be your webcam). Maybe try to display a list of the connected devices to understand which one is which. Here is an idea of the principle (work for D4XX coded in C++) :

// Create a context
rs2::context cxt;
// Get all devices connected
auto device = cxt.query_devices();
// Get number of devices
size_t device_count = device.size();
// Select the first device
auto dev = device[0];
// Display the list of connected devices
for (auto i = 0; i < device_count; i++)
{
	auto hardware = device[i];
	cout << "Name of the camera " << i << ": " << hardware.get_info(RS2_CAMERA_INFO_NAME) << endl;
}

AntoineWefit avatar Aug 24 '18 08:08 AntoineWefit

@KeCh96 Haven't tried the Python wrapper yet, but there are examples here. Always check if you have acquired data (like here). As @AntoineWefit stated, before opening a device you have to check if it's your wanted device., which can be achieved combining this and this.

vladsterz avatar Aug 24 '18 08:08 vladsterz

[Realsense Customer Engineering Team Comment] Hi KeCh96,

Wonder if you tried what were suggested by AntoineWefit and vladsterz? If there is nothing else, we are going to close this one.

Thanks!