Items with no label
3335 Discussions

Problem with enumerating the video streams

MAbdo2
New Contributor I
2,496 Views

Using the D435, when I enumerate the available video streams, I get around 90 or so different streams of different fps or resolution for the Infrared ad Range, but no stream is listed for the color. I am using the code snippet below. Yet, when I open a Pipe with the color stream data, I get color images!

Any explanation for this behavior? am I doing something wrong?

 

Thanks,

 

for (rs2::stream_profile stream_profile : stream_profiles)

{

rs2_stream stream_data_type = stream_profile.stream_type();

stream_index = stream_profile.stream_index();

stream_name = stream_profile.stream_name();

printf("Index=%d %s %d\n", ProfileIndex, stream_name, stream_data_type);

if (stream_profile.is<rs2::video_stream_profile>()) //"Is" will test if the type tested is of the type given

{

// "As" will try to convert the instance to the given type

rs2::video_stream_profile video_stream_profile = stream_profile.as<rs2::video_stream_profile>();

 

if (rs2_stream::RS2_STREAM_COLOR == stream_data_type)

MessageBox(NULL, L"Check for color", NULL, MB_OK);

//printf("Color\n");

if ((rs2_stream::RS2_STREAM_COLOR == stream_data_type) &&

(video_stream_profile.width() == _ColorImageNumberOfColumns) &&

(video_stream_profile.height() == _ColorImageNumberOfRows))

_IndexOfColorStream = ProfileIndex;

if ((rs2_stream::RS2_STREAM_DEPTH == stream_data_type) &&

(video_stream_profile.width() == _RangeImageNumberOfColumns) &&

(video_stream_profile.height() == _RangeImageNumberOfRows) &&

(video_stream_profile.fps() == RANGE_STREAM_FPS_RATE))

_IndexOfRangeStream = ProfileIndex;

std::cout << " (Video Stream: " << video_stream_profile.format() << " " << video_stream_profile.width() << "x" << video_stream_profile.height() << "@ " << video_stream_profile.fps() << "Hz)";

}

cout << std::endl;

ProfileIndex++;

}

 

0 Kudos
1 Solution
MAbdo2
New Contributor I
1,539 Views

Hi Eliza,

 

Upon using the sample, I saw the problem with my implementation, which is not a syntax/bug. Rather, a confusion caused by the different terminologies used across the literature, Essentially, my code was selecting the 1st sensor which of course is the range sensor. This sensor provides depth and IR images only. To get enumerations for the color streams, one has to select the 2nd sensor!

 

I was treating the RealSense as a "sensor" whereas one should treat it as "device" with multiple "sensors", and as such select the appropriate sensor.

 

Thank you for your help,

 

Regards,

 

Mo

View solution in original post

0 Kudos
13 Replies
MartyG
Honored Contributor III
1,539 Views

I had a very close look at the If statements in your code. The main thing I noticed is that you start with one style of bracketing in the first of the If statements and then switch to a different type for the remaining ones.

 

What I mean by this is that in the first of the statements, you write in the traditional format for bracketing, with a single opening and closing bracket.

 

if (rs2_stream::RS2_STREAM_COLOR == stream_data_type)

 

And in the subsequent If statements, the logic statements are enclosed within sub-brackets within the main open and close brackets, similar to if I was writing If ((MartyG)) instead of If (MartyG)

 

I wonder if using single-bracketing for all the If logic instead of enclosing each instruction in sub-brackets might make a difference?

0 Kudos
Eliza_D_Intel
Employee
1,539 Views
Hello MAbdo2, Thank you for your interest in the Intel RealSense D435 camera. Thank you MartyG for your inputs! Besides this, you can also use the code for rs-enumerate-devices as reference: https://github.com/IntelRealSense/librealsense/blob/master/tools/enumerate-devices/rs-enumerate-devices.cpp This application will do exactly the same thing that you want to accomplish. Also, you can check the sensor control example, as api_how_to.h contains the functions choose_a_streaming_profile - https://github.com/IntelRealSense/librealsense/blob/master/examples/sensor-control/api_how_to.h#L349 Thank you and best regards, Eliza
0 Kudos
MAbdo2
New Contributor I
1,539 Views

Thank you all for responding.

 

Elizabeth, the code I am using came from the api_how_to.h! I literally copied and pasted the code from api_how_to.h into my application. Apart from some minor alterations, I am literally running the same code as what is in api_how_to.h. which is listed below for convenience/comparison:

 

int profile_num = 0;

        for (rs2::stream_profile stream_profile : stream_profiles)

        {

            // A Stream is an abstraction for a sequence of data items of a

            // single data type, which are ordered according to their time

            // of creation or arrival.

            // The stream's data types are represented using the rs2_stream

            // enumeration

            rs2_stream stream_data_type = stream_profile.stream_type();

 

            // The rs2_stream provides only types of data which are

            // supported by the RealSense SDK

            // For example:

            //   * rs2_stream::RS2_STREAM_DEPTH describes a stream of depth images

            //   * rs2_stream::RS2_STREAM_COLOR describes a stream of color images

            //   * rs2_stream::RS2_STREAM_INFRARED describes a stream of infrared images

 

            // As mentioned, a sensor can have multiple streams.

            // In order to distinguish between streams with the same

            // stream type we can use the following methods:

 

            // 1) Each stream type can have multiple occurances.

            //   All streams, of the same type, provided from a single

            //    device have distinct indices:

            int stream_index = stream_profile.stream_index();

 

            // 2) Each stream has a user-friendly name.

            //   The stream's name is not promised to be unique,

            //    rather a human readable description of the stream

            std::string stream_name = stream_profile.stream_name();

 

            // 3) Each stream in the system, which derives from the same

            //    rs2::context, has a unique identifier

            //   This identifier is unique across all streams, regardless of the stream type.

            int unique_stream_id = stream_profile.unique_id(); // The unique identifier can be used for comparing two streams

            std::cout << std::setw(3) << profile_num << ": " << stream_data_type << " #" << stream_index;

 

            // As noted, a stream is an abstraction.

            // In order to get additional data for the specific type of a

            // stream, a mechanism of "Is" and "As" is provided:

            if (stream_profile.is<rs2::video_stream_profile>()) //"Is" will test if the type tested is of the type given

            {

                // "As" will try to convert the instance to the given type

                rs2::video_stream_profile video_stream_profile = stream_profile.as<rs2::video_stream_profile>();

 

                // After using the "as" method we can use the new data type

                // for additinal operations:

                std::cout << " (Video Stream: " << video_stream_profile.format() << " " <<

                    video_stream_profile.width() << "x" << video_stream_profile.height() << "@ " << video_stream_profile.fps() << "Hz)";

            }

            std::cout << std::endl;

            profile_num++;

        }

 

It would be really helpful is someone could use the same code as above and verify that the api_how_to.h code actually produces the expected results.

 

Suggestions are welcome.

 

Regards,

 

Mo

0 Kudos
Eliza_D_Intel
Employee
1,539 Views
Hello MAbdo2, Could you please provide us a screenshot or text output of the api_how_to code? Thank you, Eliza
0 Kudos
MAbdo2
New Contributor I
1,539 Views

Hello Eliza,

 

Thank you for following up.

 

I am providing you the following/attached.

1) Snippet of my actual code where I enumerate the streams

2) Picture showing the snippet of my code

3) Picture showing the snippet of the api_how_to

 

Regards,

 

Mo

// Using the sensor we can get all of its streaming profiles std::vector<rs2::stream_profile> stream_profiles = _Sensor[_NumberOfSensors].get_stream_profiles(); //Next, we go over all the stream profiles and print the details of each one // std::cout << "Sensor provides the following stream profiles:" << std::endl; int ProfileIndex = 0; int stream_index; std::string stream_name; _IndexOfRangeStream = _IndexOfColorStream = -1; for (rs2::stream_profile stream_profile : stream_profiles) { rs2_stream stream_data_type = stream_profile.stream_type(); stream_index = stream_profile.stream_index(); stream_name = stream_profile.stream_name(); printf("Index=%d %s %d\n", ProfileIndex, stream_name, stream_data_type); if (stream_profile.is<rs2::video_stream_profile>()) //"Is" will test if the type tested is of the type given { // "As" will try to convert the instance to the given type rs2::video_stream_profile video_stream_profile = stream_profile.as<rs2::video_stream_profile>(); if (rs2_stream::RS2_STREAM_COLOR == stream_data_type) MessageBox(NULL, L"Check for color", NULL, MB_OK); //printf("Color\n"); if ((rs2_stream::RS2_STREAM_COLOR == stream_data_type) && (video_stream_profile.width() == _ColorImageNumberOfColumns) && (video_stream_profile.height() == _ColorImageNumberOfRows)) _IndexOfColorStream = ProfileIndex; if ((rs2_stream::RS2_STREAM_DEPTH == stream_data_type) && (video_stream_profile.width() == _RangeImageNumberOfColumns) && (video_stream_profile.height() == _RangeImageNumberOfRows) && (video_stream_profile.fps() == RANGE_STREAM_FPS_RATE)) _IndexOfRangeStream = ProfileIndex;   std::cout << " (Video Stream: " << video_stream_profile.format() << " " << video_stream_profile.width() << "x" << video_stream_profile.height() << "@ " << video_stream_profile.fps() << "Hz)"; } cout << std::endl; ProfileIndex++; } printf("_IndexOfRangeStream=%d _IndexOfColorStream=%d\n", _IndexOfRangeStream, _IndexOfColorStream); // _Sensor[_NumberOfSensors++].open(stream_profiles[68]); _Sensor[_NumberOfSensors++].open(stream_profiles[_IndexOfRangeStream]); printf("ALV_IntelRealsenseRS2 : ALV_IntelRealSenseRS2_Initialize : All seems to be OK\n"); return true;

Snippet of how_to_api.pngSnippet of my actual code.bmp

0 Kudos
Eliza_D_Intel
Employee
1,539 Views
Hello MAbdo2, Thank you! We are interested to see what is the output you receive when running this code. Thank you, Eliza
0 Kudos
MAbdo2
New Contributor I
1,539 Views

The output of the program for the section that relates to the enumeration is listed below. As can be seen, the software detects 96 different streams but none is for the color camera.

 

Regards,

 

Mo

 

Index=0 Infrared 1 3

 (Video Stream: Y8 1280x800@ 30Hz)

Index=1 Infrared 2 3

 (Video Stream: Y8 1280x800@ 30Hz)

Index=2 Infrared 1 3

 (Video Stream: Y16 1280x800@ 25Hz)

Index=3 Infrared 2 3

 (Video Stream: Y16 1280x800@ 25Hz)

Index=4 Infrared 1 3

 (Video Stream: Y16 1280x800@ 15Hz)

Index=5 Infrared 2 3

 (Video Stream: Y16 1280x800@ 15Hz)

Index=6 Infrared 1 3

 (Video Stream: Y8 1280x800@ 15Hz)

Index=7 Infrared 2 3

 (Video Stream: Y8 1280x800@ 15Hz)

Index=8 Infrared 2 3

 (Video Stream: Y8 1280x720@ 30Hz)

Index=9 Infrared 1 3

 (Video Stream: Y8 1280x720@ 30Hz)

Index=10 Infrared 2 3

 (Video Stream: Y8 1280x720@ 15Hz)

Index=11 Infrared 1 3

 (Video Stream: Y8 1280x720@ 15Hz)

Index=12 Infrared 2 3

 (Video Stream: Y8 1280x720@ 6Hz)

Index=13 Infrared 1 3

 (Video Stream: Y8 1280x720@ 6Hz)

Index=14 Infrared 2 3

 (Video Stream: Y8 848x480@ 90Hz)

Index=15 Infrared 1 3

 (Video Stream: Y8 848x480@ 90Hz)

Index=16 Infrared 2 3

 (Video Stream: Y8 848x480@ 60Hz)

Index=17 Infrared 1 3

 (Video Stream: Y8 848x480@ 60Hz)

Index=18 Infrared 1 3

 (Video Stream: Y8 848x480@ 30Hz)

Index=19 Infrared 2 3

 (Video Stream: Y8 848x480@ 30Hz)

Index=20 Infrared 2 3

 (Video Stream: Y8 848x480@ 15Hz)

Index=21 Infrared 1 3

 (Video Stream: Y8 848x480@ 15Hz)

Index=22 Infrared 2 3

 (Video Stream: Y8 848x480@ 6Hz)

Index=23 Infrared 1 3

 (Video Stream: Y8 848x480@ 6Hz)

Index=24 Infrared 1 3

 (Video Stream: Y8 640x480@ 90Hz)

Index=25 Infrared 2 3

 (Video Stream: Y8 640x480@ 90Hz)

Index=26 Infrared 1 3

 (Video Stream: Y8 640x480@ 60Hz)

Index=27 Infrared 2 3

 (Video Stream: Y8 640x480@ 60Hz)

Index=28 Infrared 2 3

 (Video Stream: Y8 640x480@ 30Hz)

Index=29 Infrared 1 3

 (Video Stream: Y8 640x480@ 30Hz)

Index=30 Infrared 1 3

 (Video Stream: Y8 640x480@ 15Hz)

Index=31 Infrared 2 3

 (Video Stream: Y8 640x480@ 15Hz)

Index=32 Infrared 2 3

 (Video Stream: Y8 640x480@ 6Hz)

Index=33 Infrared 1 3

 (Video Stream: Y8 640x480@ 6Hz)

Index=34 Infrared 1 3

 (Video Stream: Y16 640x400@ 25Hz)

Index=35 Infrared 2 3

 (Video Stream: Y16 640x400@ 25Hz)

Index=36 Infrared 2 3

 (Video Stream: Y16 640x400@ 15Hz)

Index=37 Infrared 1 3

 (Video Stream: Y16 640x400@ 15Hz)

Index=38 Infrared 2 3

 (Video Stream: Y8 640x360@ 90Hz)

Index=39 Infrared 1 3

 (Video Stream: Y8 640x360@ 90Hz)

Index=40 Infrared 1 3

 (Video Stream: Y8 640x360@ 60Hz)

Index=41 Infrared 2 3

 (Video Stream: Y8 640x360@ 60Hz)

Index=42 Infrared 2 3

 (Video Stream: Y8 640x360@ 30Hz)

Index=43 Infrared 1 3

 (Video Stream: Y8 640x360@ 30Hz)

Index=44 Infrared 1 3

 (Video Stream: Y8 640x360@ 15Hz)

Index=45 Infrared 2 3

 (Video Stream: Y8 640x360@ 15Hz)

Index=46 Infrared 1 3

 (Video Stream: Y8 640x360@ 6Hz)

Index=47 Infrared 2 3

 (Video Stream: Y8 640x360@ 6Hz)

Index=48 Infrared 1 3

 (Video Stream: Y8 480x270@ 90Hz)

Index=49 Infrared 2 3

 (Video Stream: Y8 480x270@ 90Hz)

Index=50 Infrared 1 3

 (Video Stream: Y8 480x270@ 60Hz)

Index=51 Infrared 2 3

 (Video Stream: Y8 480x270@ 60Hz)

Index=52 Infrared 1 3

 (Video Stream: Y8 480x270@ 30Hz)

Index=53 Infrared 2 3

 (Video Stream: Y8 480x270@ 30Hz)

Index=54 Infrared 1 3

 (Video Stream: Y8 480x270@ 15Hz)

Index=55 Infrared 2 3

 (Video Stream: Y8 480x270@ 15Hz)

Index=56 Infrared 2 3

 (Video Stream: Y8 480x270@ 6Hz)

Index=57 Infrared 1 3

 (Video Stream: Y8 480x270@ 6Hz)

Index=58 Infrared 2 3

 (Video Stream: Y8 424x240@ 90Hz)

Index=59 Infrared 1 3

 (Video Stream: Y8 424x240@ 90Hz)

Index=60 Infrared 1 3

 (Video Stream: Y8 424x240@ 60Hz)

Index=61 Infrared 2 3

 (Video Stream: Y8 424x240@ 60Hz)

Index=62 Infrared 2 3

 (Video Stream: Y8 424x240@ 30Hz)

Index=63 Infrared 1 3

 (Video Stream: Y8 424x240@ 30Hz)

Index=64 Infrared 2 3

 (Video Stream: Y8 424x240@ 15Hz)

Index=65 Infrared 1 3

 (Video Stream: Y8 424x240@ 15Hz)

Index=66 Infrared 2 3

 (Video Stream: Y8 424x240@ 6Hz)

Index=67 Infrared 1 3

 (Video Stream: Y8 424x240@ 6Hz)

Index=68 Depth 1

 (Video Stream: Z16 1280x720@ 30Hz)

Index=69 Depth 1

 (Video Stream: Z16 1280x720@ 15Hz)

Index=70 Depth 1

 (Video Stream: Z16 1280x720@ 6Hz)

Index=71 Depth 1

 (Video Stream: Z16 848x480@ 90Hz)

Index=72 Depth 1

 (Video Stream: Z16 848x480@ 60Hz)

Index=73 Depth 1

 (Video Stream: Z16 848x480@ 30Hz)

Index=74 Depth 1

 (Video Stream: Z16 848x480@ 15Hz)

Index=75 Depth 1

 (Video Stream: Z16 848x480@ 6Hz)

Index=76 Depth 1

 (Video Stream: Z16 640x480@ 90Hz)

Index=77 Depth 1

 (Video Stream: Z16 640x480@ 60Hz)

Index=78 Depth 1

 (Video Stream: Z16 640x480@ 30Hz)

Index=79 Depth 1

 (Video Stream: Z16 640x480@ 15Hz)

Index=80 Depth 1

 (Video Stream: Z16 640x480@ 6Hz)

Index=81 Depth 1

 (Video Stream: Z16 640x360@ 90Hz)

Index=82 Depth 1

 (Video Stream: Z16 640x360@ 60Hz)

Index=83 Depth 1

 (Video Stream: Z16 640x360@ 30Hz)

Index=84 Depth 1

 (Video Stream: Z16 640x360@ 15Hz)

Index=85 Depth 1

 (Video Stream: Z16 640x360@ 6Hz)

Index=86 Depth 1

 (Video Stream: Z16 480x270@ 90Hz)

Index=87 Depth 1

 (Video Stream: Z16 480x270@ 60Hz)

Index=88 Depth 1

 (Video Stream: Z16 480x270@ 30Hz)

Index=89 Depth 1

 (Video Stream: Z16 480x270@ 15Hz)

Index=90 Depth 1

 (Video Stream: Z16 480x270@ 6Hz)

Index=91 Depth 1

 (Video Stream: Z16 424x240@ 90Hz)

Index=92 Depth 1

 (Video Stream: Z16 424x240@ 60Hz)

Index=93 Depth 1

 (Video Stream: Z16 424x240@ 30Hz)

Index=94 Depth 1

 (Video Stream: Z16 424x240@ 15Hz)

Index=95 Depth 1

 (Video Stream: Z16 424x240@ 6Hz)

 

0 Kudos
Eliza_D_Intel
Employee
1,539 Views
Hello MAbdo2, Could you please confirm that sensor-control and enumerate-devices examples work as expected with your D435 camera? If they work well and the color streams profiles are being recognized, the problem is somewhere in your code. If you do not see the color stream when running these examples, then the camera might be faulty. Thank you and best regards, Eliza
0 Kudos
MAbdo2
New Contributor I
1,539 Views

Hi Eliza,

 

I tried to compile and build the sensor control example but realized that this example (and associated code) does not port directly to Windows OS. In fact, the port to Windows is a fair bit of effort. So, I gave up in doing so. If you (or anyone else) can provide a ready-to-go executable that runs on Windows, then I can try.

Additionally, I have three (3) D435 sensors and they all behave the same way when running my code. So, I don't believe they are all faulty. Also, I can start a pipe and stream color video, so the Real Sense device works OK, it is just the enumeration code that does not work right.

 

Thanks and regards,

 

Mo

0 Kudos
Eliza_D_Intel
Employee
1,539 Views
Hello MAbdo2, I did not encounter these issues after building the solution. If you have previously build the solution from Intel RealSense SDK 2.0, you will have a folder called Debug/Release. Copy the path to this folder, open CMD, and go to that path. For me, it looks something like this: cd C:\GIT\librealsense-2.17.0\build\Debug In the same Terminal, run: rs-enumerate-devices.exe and rs-sensor-control.exe If you did not build the solution, please follow this guide on how to do that: https://www.intel.com/content/www/us/en/support/articles/000030463/emerging-technologies/intel-realsense-technology.html Looking forward to your response! Best regards, Eliza
0 Kudos
MAbdo2
New Contributor I
1,540 Views

Hi Eliza,

 

Upon using the sample, I saw the problem with my implementation, which is not a syntax/bug. Rather, a confusion caused by the different terminologies used across the literature, Essentially, my code was selecting the 1st sensor which of course is the range sensor. This sensor provides depth and IR images only. To get enumerations for the color streams, one has to select the 2nd sensor!

 

I was treating the RealSense as a "sensor" whereas one should treat it as "device" with multiple "sensors", and as such select the appropriate sensor.

 

Thank you for your help,

 

Regards,

 

Mo

0 Kudos
Eliza_D_Intel
Employee
1,539 Views
Hello MAbdo2, I am glad that you solved your issue! Thank you and best regards, Eliza
0 Kudos
Eliza_D_Intel
Employee
1,539 Views
Hello MAbdo2, As another option to use the samples, you can download and install the SDK binary from: https://github.com/IntelRealSense/librealsense/releases/download/v2.18.1/Intel.RealSense.SDK-2.18.1.exe. This will give you the tools executable (including rs-enumerate-devices.exe) and a Visual Studio solution file you can use to build the samples. The SDK will be installed to C:\Program Files (x86)\Intel RealSense SDK 2.0\. You can look under .\samples for the rs-examples.sln file which can be used to build the samples, including sensor-control. The resulting .exe files will be in .\samples\<x64 or x86>\<Debug or Release>\ Thank you and best regards, Eliza
0 Kudos
Reply