-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26fa554
commit b5fbe30
Showing
14 changed files
with
100 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright(c) 2021 Intel Corporation. All Rights Reserved. | ||
|
||
#pragma once | ||
#include <iostream> | ||
#include <string> | ||
#include <map> | ||
#include <librealsense2/rs.hpp> | ||
|
||
////////////////////////////// | ||
// Demos Helpers // | ||
////////////////////////////// | ||
|
||
// Find devices with specified streams | ||
bool device_with_streams(std::vector <rs2_stream> stream_requests, std::string& out_serial) | ||
{ | ||
rs2::context ctx; | ||
auto devs = ctx.query_devices(); | ||
std::vector <rs2_stream> unavailable_streams = stream_requests; | ||
for (auto& dev : devs) | ||
{ | ||
std::map<rs2_stream, bool> found_streams; | ||
for (auto& type : stream_requests) | ||
{ | ||
found_streams[type] = false; | ||
for (auto& sensor : dev.query_sensors()) | ||
{ | ||
for (auto& profile : sensor.get_stream_profiles()) | ||
{ | ||
if (profile.stream_type() == type) | ||
{ | ||
found_streams[type] = true; | ||
unavailable_streams.erase(std::remove(unavailable_streams.begin(), unavailable_streams.end(), type), unavailable_streams.end()); | ||
if (dev.supports(RS2_CAMERA_INFO_SERIAL_NUMBER)) | ||
out_serial = dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER); | ||
} | ||
} | ||
} | ||
} | ||
// Check if all streams are found in current device | ||
bool found_all_streams = true; | ||
for (auto& stream : found_streams) | ||
{ | ||
if (!stream.second) | ||
{ | ||
found_all_streams = false; | ||
break; | ||
} | ||
} | ||
if (found_all_streams) | ||
return true; | ||
} | ||
// After scanning all devices, not all requested streams were found | ||
for (auto& type : unavailable_streams) | ||
{ | ||
switch (type) | ||
{ | ||
case RS2_STREAM_POSE: | ||
case RS2_STREAM_FISHEYE: | ||
std::cerr << "Connect T26X and rerun the demo" << std::endl; | ||
break; | ||
case RS2_STREAM_DEPTH: | ||
std::cerr << "The demo requires Realsense camera with DEPTH sensor" << std::endl; | ||
break; | ||
case RS2_STREAM_COLOR: | ||
std::cerr << "The demo requires Realsense camera with RGB sensor" << std::endl; | ||
break; | ||
default: | ||
throw std::runtime_error("The requested stream: " + std::to_string(type) + ", for the demo is not supported by connected devices!"); // stream type | ||
} | ||
} | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,6 @@ | |
import cv2 | ||
import numpy as np | ||
import pyrealsense2 as rs | ||
context = rs.context() | ||
|
||
class AppState: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters