Skip to content

Commit

Permalink
enabling the requested profiles with D405, using pipe API
Browse files Browse the repository at this point in the history
  • Loading branch information
remibettan committed Jul 19, 2021
1 parent 400571d commit a10a92f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,16 @@ void device::tag_profiles(stream_profiles profiles) const

bool device::contradicts(const stream_profile_interface* a, const std::vector<stream_profile>& others) const
{
bool is_d405 = (get_info(RS2_CAMERA_INFO_PRODUCT_ID) == "0B5B");
if (auto vid_a = dynamic_cast<const video_stream_profile_interface*>(a))
{
for (auto request : others)
{
if (a->get_framerate() != 0 && request.fps != 0 && (a->get_framerate() != request.fps))
return true;
if (vid_a->get_width() != 0 && request.width != 0 && (vid_a->get_width() != request.width))
if (vid_a->get_width() != 0 && request.width != 0 && (vid_a->get_width() != request.width) && (!(is_d405 && vid_a->get_width() == 1280 && request.width == 1288)))
return true;
if (vid_a->get_height() != 0 && request.height != 0 && (vid_a->get_height() != request.height))
if (vid_a->get_height() != 0 && request.height != 0 && (vid_a->get_height() != request.height) && (!(is_d405 && vid_a->get_height() == 720 && request.height == 808)))
return true;
}
}
Expand Down
46 changes: 43 additions & 3 deletions src/pipeline/resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,20 @@ namespace librealsense
if (!has_wildcards(request)) continue;
for (auto candidate : candidates)
{
if (match(candidate.get(), request) && !dev->contradicts(candidate.get(), requests))
//if (match(candidate.get(), request) && !dev->contradicts(candidate.get(), requests))
if (match(candidate.get(), request))
{
request = to_request(candidate.get());
break;
if (candidate.get()->get_stream_type() == RS2_STREAM_COLOR &&
candidate.get()->get_format() == RS2_FORMAT_RGB8 &&
candidate.get()->get_framerate() == 15)
{
int a = 1;
}
if (!dev->contradicts(candidate.get(), requests))
{
request = to_request(candidate.get());
break;
}
}
}
if (has_wildcards(request))
Expand Down Expand Up @@ -409,6 +419,36 @@ namespace librealsense

if (targets.size() > 0) // if subdevice is handling any streams
{
// moving the infrared profile to first position if it is requested
if (dev->get_info(RS2_CAMERA_INFO_PRODUCT_ID) == "0B5B" && targets.size() > 1)
{
// moving the infrared profile to first position if it is requested
int ir_index = -1;
for (int i = 0; i < targets.size(); ++i)
{
if (targets[i].stream == RS2_STREAM_INFRARED)
{
ir_index = i;
break;
}
}
// ir_index not -1: means that the ir profile has been found in targets
// ir_index not 0: means that the ir profile is not in targets's first position
if (ir_index != -1 && ir_index != 0)
{
std::swap(targets[0], targets[ir_index]);
}
/*auto it = std::find(targets.begin(), targets.end(), [&](const stream_profile& sp) {
return sp.stream == RS2_STREAM_INFRARED;
});
if (it != targets.end()) // means that the ir profile has been found in targets
{
stream_profile ir_sp = *it;
targets.erase(it);
targets.
}*/
}

auto_complete(targets, profiles, dev);

for (auto && t : targets)
Expand Down

0 comments on commit a10a92f

Please sign in to comment.