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

Enabling LRS examples/tutorials on SR306 #8749

Merged
merged 15 commits into from
May 13, 2021

Conversation

nohayassin
Copy link
Contributor

@nohayassin nohayassin commented Apr 6, 2021

Track on: DSO-16721

@nohayassin nohayassin changed the title Enabling LRS examples/tutorials to work with SR306 Enabling LRS examples/tutorials on SR306 Apr 6, 2021
examples/align/rs-align.cpp Outdated Show resolved Hide resolved
examples/align/rs-align.cpp Outdated Show resolved Hide resolved
examples/align/rs-align.cpp Outdated Show resolved Hide resolved
examples/align/rs-align.cpp Outdated Show resolved Hide resolved
examples/align/rs-align.cpp Outdated Show resolved Hide resolved
examples/measure/rs-measure.cpp Outdated Show resolved Hide resolved
examples/align/rs-align.cpp Outdated Show resolved Hide resolved
examples/pose-and-image/rs-pose-and-image.cpp Outdated Show resolved Hide resolved
@nohayassin nohayassin force-pushed the dso_16719_demo branch 3 times, most recently from 383a508 to 134d609 Compare April 11, 2021 06:30
examples/align/rs-align.cpp Outdated Show resolved Hide resolved
examples/ar-advanced/rs-ar-advanced.cpp Outdated Show resolved Hide resolved
examples/example.hpp Outdated Show resolved Hide resolved
examples/ar-advanced/rs-ar-advanced.cpp Outdated Show resolved Hide resolved
wrappers/python/examples/align-depth2color.py Outdated Show resolved Hide resolved
wrappers/python/examples/opencv_pointcloud_viewer.py Outdated Show resolved Hide resolved
wrappers/python/examples/opencv_viewer_example.py Outdated Show resolved Hide resolved
examples/align/rs-align.cpp Outdated Show resolved Hide resolved
examples/example.hpp Outdated Show resolved Hide resolved
examples/example.hpp Outdated Show resolved Hide resolved
@@ -1082,9 +1082,8 @@ std::string depth_with_stream_type_present(rs2_stream type)
for (auto profile : sensor.get_stream_profiles())
{
if (profile.stream_type() == type)
return dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER);
out_serial = dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Check for dev.supports(RS2_CAMERA_INFO_SERIAL_NUMBER) before the attribute query

wrappers/python/examples/align-depth2color.py Outdated Show resolved Hide resolved
wrappers/python/examples/opencv_pointcloud_viewer.py Outdated Show resolved Hide resolved
examples/pose-and-image/rs-pose-and-image.cpp Outdated Show resolved Hide resolved
examples/align/rs-align.cpp Outdated Show resolved Hide resolved
examples/ar-advanced/rs-ar-advanced.cpp Outdated Show resolved Hide resolved
}
}
}
if (out_serial.empty())
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the flow will select device even if not all the required streams are supported.
Please check and refactor accordingly

Copy link
Collaborator

Choose a reason for hiding this comment

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

Still applies

for (auto type : types)
{
bool stream_found = false;
for (auto dev : ctx.query_devices())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use auto& here and below

examples/example.hpp Outdated Show resolved Hide resolved
examples/example.hpp Outdated Show resolved Hide resolved
examples/example.hpp Outdated Show resolved Hide resolved
examples/example.hpp Outdated Show resolved Hide resolved
examples/measure/rs-measure.cpp Outdated Show resolved Hide resolved
examples/pose-and-image/rs-pose-and-image.cpp Outdated Show resolved Hide resolved
types.push_back(RS2_STREAM_COLOR);
types.push_back(RS2_STREAM_DEPTH);
if (!device_with_streams(types, serial))
if (!device_with_streams({ RS2_STREAM_POSE,RS2_STREAM_FISHEYE }, serial))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Request Depth +RGB

{
bool stream_found = false;
for (auto dev : ctx.query_devices())
for (auto& dev : devs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

The check must be reset between iterations and counted per device to avoid false positives

std::cerr << "Connect T26X and rerun the demo";
return false;
case RS2_STREAM_DEPTH:
case RS2_STREAM_COLOR:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be handled as two separate entities

std::cerr << "The demo requires Realsense camera with DEPTH and RGB sensors";
return false;
default:
throw std::runtime_error("The requested stream: " + std::to_string(type) + ", is not supported by this demo!"); // stream type
Copy link
Collaborator

Choose a reason for hiding this comment

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

is not supported by this demo! " for the demo is not supported by connected devices"

{
for (auto profile : sensor.get_stream_profiles())
for (auto& profile : sensor.get_stream_profiles())
{
if (profile.stream_type() == type && dev.supports(RS2_CAMERA_INFO_SERIAL_NUMBER))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move the && dev.supports(RS2_CAMERA_INFO_SERIAL_NUMBER) within the clause, as discussed

@@ -137,7 +137,8 @@ int main(int argc, char * argv[]) try
rs2::pipeline pipe;

rs2::config cfg;
cfg.enable_device(serial);
if (!serial.empty())
Copy link
Collaborator

Choose a reason for hiding this comment

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

All the Pose/FE demos needs to be retested with T265

Comment on lines 31 to 35
try:
next(s for s in sensorsList if s.get_info(rs.camera_info.name) == 'RGB Camera')
except Exception as e:
print("The connected device does not support RGB stream")
exit(0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Replace try/catch with check routine in python similar to C++ examples. Here and in the next two demos

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need more clarification here:

  1. There is no common file for python examples where I can put the check method and I don't think creating a common file especially for that is reasonable. What do you suggest ?
  2. Should the method be exactly as in C++ (checking serial etc ) ?

Copy link
Collaborator

@ev-mp ev-mp left a comment

Choose a reason for hiding this comment

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

A minor remark for python part

@@ -12,19 +12,27 @@
# Import OpenCV for easy image rendering
import cv2

context = rs.context()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it used?

@@ -30,7 +30,7 @@
import cv2
import numpy as np
import pyrealsense2 as rs

context = rs.context()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here

@@ -12,13 +12,23 @@
# Configure depth and color streams
pipeline = rs.pipeline()
config = rs.config()
context = rs.context()
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

@@ -3,6 +3,7 @@

#include <librealsense2/rs.hpp>
#include "example-imgui.hpp"
#include "../examples/example-utils.hpp"
Copy link
Collaborator

Choose a reason for hiding this comment

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

refactor so that examples-utils.hpp is listed in examples.hpp so the change will be transparent to the users of the latter
Drop relative path and use local notation "examples-utils.hpp"

@@ -206,6 +207,10 @@ class gl_blocks : public suite

int main(int argc, char** argv) try
{
std::string serial;
if (!device_with_streams({ RS2_STREAM_COLOR,RS2_STREAM_DEPTH }, serial))
Copy link
Collaborator

Choose a reason for hiding this comment

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

make the demo utilize IR stream if color is not present.
test flow-

  1. Depth stream - must
    2 . Color or Infrared stream (2nd priority) - must

found_rgb = True
break
if not found_rgb:
print("The connected device does not support RGB stream")
Copy link
Collaborator

Choose a reason for hiding this comment

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

The connected device does not support RGB stream - " The demo requires Depth camera with Color sensor".

@@ -6,13 +6,20 @@
#include <chrono>
#include <thread>
#include <mutex>
#include "example.hpp"
Copy link
Collaborator

Choose a reason for hiding this comment

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

replace with example-utils.hpp

@@ -9,6 +9,7 @@

#include <math.h>
#include <float.h>
#include "example.hpp"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here

@@ -3,13 +3,20 @@
#include <librealsense2/rs.hpp>
#include <iostream>
#include <iomanip>
#include "example.hpp"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here

second_stream = ir_stream;
else
{
std::cout<< " Connect a device that supports either RGB stream or Infrared stream." <<std::endl;
Copy link
Collaborator

Choose a reason for hiding this comment

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

~~ a device~~ Depth Camera ... RGB stream or Infrared streams

@@ -14,17 +14,24 @@

# Create a pipeline
pipeline = rs.pipeline()

Copy link
Collaborator

Choose a reason for hiding this comment

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

Revert

# Create a config and configure the pipeline to stream
# different resolutions of color and depth streams
config = rs.config()

Copy link
Collaborator

Choose a reason for hiding this comment

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

revert

Copy link
Collaborator

@ev-mp ev-mp left a comment

Choose a reason for hiding this comment

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

Minor fix in rs-benchmark

tools/benchmark/rs-benchmark.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@ev-mp ev-mp left a comment

Choose a reason for hiding this comment

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

Approved

@ev-mp ev-mp merged commit b734940 into IntelRealSense:development May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants