rs2::frame yuy2rgb::process_frame(const rs2::frame_source& source, const rs2::frame& f) { auto p = f.get_profile(); if (p.get() != _source_stream_profile.get()) { _source_stream_profile = p; _target_stream_profile = p.clone(p.stream_type(), p.stream_index(), RS2_FORMAT_RGB8); } rs2::frame ret; auto vf = f.as<rs2::video_frame>(); ret = source.allocate_video_frame(_target_stream_profile, f, _traget_bpp, vf.get_width(), vf.get_height(), vf.get_width() * _traget_bpp, RS2_EXTENSION_VIDEO_FRAME); byte* planes[1]; planes[0] = (byte*)ret.get_data(); unpack_yuy2_rgb8(planes, (const byte*)f.get_data(), vf.get_width(), vf.get_height()); return ret; }
bool align::should_process(const rs2::frame& frame) { if (!frame) return false; auto set = frame.as<rs2::frameset>(); if (!set) return false; auto profile = frame.get_profile(); rs2_stream stream = profile.stream_type(); rs2_format format = profile.format(); int index = profile.stream_index(); //process composite frame only if it contains both a depth frame and the requested texture frame bool has_tex = false, has_depth = false; set.foreach([this, &has_tex](const rs2::frame& frame) { if (frame.get_profile().stream_type() == _to_stream_type) has_tex = true; }); set.foreach([&has_depth](const rs2::frame& frame) { if (frame.get_profile().stream_type() == RS2_STREAM_DEPTH && frame.get_profile().format() == RS2_FORMAT_Z16) has_depth = true; }); if (!has_tex || !has_depth) return false; return true; }
bool pointcloud::should_process(const rs2::frame& frame) { if (!frame) return false; auto set = frame.as<rs2::frameset>(); if (set) { //process composite frame only if it contains both a depth frame and the requested texture frame if (_stream_filter.stream == RS2_STREAM_ANY) return false; auto tex = set.first_or_default(_stream_filter.stream, _stream_filter.format); if (!tex) return false; auto depth = set.first_or_default(RS2_STREAM_DEPTH, RS2_FORMAT_Z16); if (!depth) return false; } else { if (frame.get_profile().stream_type() == RS2_STREAM_DEPTH && frame.get_profile().format() == RS2_FORMAT_Z16) return true; auto p = frame.get_profile(); if (p.stream_type() == _stream_filter.stream && p.format() == _stream_filter.format && p.stream_index() == _stream_filter.index) return true; return false; //TODO: switch to this code when map_to api is removed //if (_stream_filter != RS2_STREAM_ANY) // return false; //process single frame only if it is a depth frame //if (frame.get_profile().stream_type() != RS2_STREAM_DEPTH || frame.get_profile().format() != RS2_FORMAT_Z16) // return false; } return true; }