6 #include <opencv2/opencv.hpp> 47 cv::resize(ir,
_decimated_ir, cv::Size(), DOWNSAMPLE_FRACTION, DOWNSAMPLE_FRACTION, cv::INTER_NEAREST);
54 const auto num_sub_images =
sub_areas.size();
56 #pragma omp parallel for 57 for (
int i = 0;
i < num_sub_images;
i++)
65 cv::MORPH_OPEN, cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(3, 3)));
78 auto ir_frame =
frames.get_infrared_frame();
100 cv::Mat matGray(cv::Size(ir_frame.get_width(), ir_frame.get_height()), CV_8U, (
void*)ir_frame.get_data(), cv::Mat::AUTO_STEP);
112 newW, newH, ir_frame.get_bytes_per_pixel() * newW);
113 memcpy((
void*)res_ir.get_data(),
_decimated_ir.data, newW * newH);
117 memcpy((
void*)res_depth.get_data(),
_depth_output.data, newW * newH * 2);
119 std::vector<rs2::frame> fs{ res_ir, res_depth };
169 cv::threshold(area->
corners, area->
corners, 300, 255, cv::THRESH_BINARY);
185 const int sizeX = ir_resized.cols;
186 const int sizeY = ir_resized.rows;
188 const int sizeXtimesSizeY = sizeX * sizeY;
191 bool needToReinitialize = _mask_edge.size() != ir_resized.size() || _mask_edge.type() != CV_8U;
193 if (!needToReinitialize)
196 memset(_depth_output.data, 0, 2 * sizeXtimesSizeY);
200 static_assert(NUM_SUB_IMAGES >= 1 && NUM_SUB_IMAGES < 64,
"NUM_SUB_IMAGES value might be wrong");
202 _mask_edge = cv::Mat(ir_resized.size(), CV_8U);
203 _mask_harris = cv::Mat(ir_resized.size(), CV_8U);
204 _mask_combined = cv::Mat(ir_resized.size(), CV_8U);
205 _depth_output = cv::Mat(ir_resized.size(), CV_16U);
206 _ir_float = cv::Mat(ir_resized.size(), CV_32F);
207 _corners = cv::Mat(ir_resized.size(), CV_32F);
208 _scharr_x = cv::Mat(ir_resized.size(), CV_16S);
209 _scharr_y = cv::Mat(ir_resized.size(), CV_16S);
210 _abs_scharr_x = cv::Mat(ir_resized.size(), CV_8U);
211 _abs_scharr_y = cv::Mat(ir_resized.size(), CV_8U);
214 memset(_depth_output.data, 0, 2 * sizeXtimesSizeY);
216 std::vector<cv::Rect> rects;
219 cv::Rect
rect(0,
i * sizeYperSubImage, sizeX, sizeYperSubImage);
220 rects.push_back(rect);
223 for (
auto&&
rect : rects)
238 sub_areas.push_back(si);
243 int main(
int argc,
char * argv[])
try 258 const auto window_name =
"Display Image";
259 namedWindow(window_name, WINDOW_AUTOSIZE);
264 std::ifstream file(
"./camera-settings.json");
267 std::string str((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
272 advanced.load_json(str);
277 std::cout <<
"Couldn't find camera-settings.json, skipping custom settings!" << std::endl;
282 while (waitKey(1) < 0 && getWindowProperty(window_name, WND_PROP_AUTOSIZE) >= 0)
295 Mat
image(Size(w, h), CV_8UC3, (
void*)depth.
get_data(), Mat::AUTO_STEP);
298 imshow(window_name,
image);
308 catch (
const std::exception& e)
frame apply_filter(filter_interface &filter)
frameset wait_for_frames(unsigned int timeout_ms=RS2_DEFAULT_TIMEOUT) const
void downsample_min_4x4(const cv::Mat &source, cv::Mat *pDest)
void downsample(const cv::Mat &depth, const cv::Mat &ir)
static constexpr auto DOWNSAMPLE_FACTOR
rs2::stream_profile _input_depth_profile
void filter_edges(sub_area *area)
GLint GLint GLsizei GLsizei GLsizei depth
const void * get_data() const
GLdouble GLdouble GLdouble w
GLsizei const GLchar *const * string
GLfloat GLfloat GLfloat GLfloat h
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
void frame_ready(frame result) const
GLenum GLenum GLsizei void * image
depth_frame get_depth_frame() const
frame allocate_video_frame(const stream_profile &profile, const frame &original, int new_bpp=0, int new_width=0, int new_height=0, int new_stride=0, rs2_extension frame_type=RS2_EXTENSION_VIDEO_FRAME) const
rs2::stream_profile _input_ir_profile
const std::string & get_failed_args() const
static constexpr size_t NUM_SUB_IMAGES
void sdk_handle(rs2::frame &f, rs2::frame_source &src)
std::vector< sub_area > sub_areas
void filter_harris(sub_area *area)
rs2::stream_profile _output_depth_profile
frame allocate_composite_frame(std::vector< frame > frames) const
void enable_stream(rs2_stream stream_type, int stream_index, int width, int height, rs2_format format=RS2_FORMAT_ANY, int framerate=0)
filter(std::shared_ptr< rs2_processing_block > block, int queue_size=1)
pipeline_profile resolve(std::shared_ptr< rs2_pipeline > p) const
int main(int argc, char *argv[])
const rs2_stream_profile * get() const
rs2_intrinsics operator/(const rs2_intrinsics &i, int f)
stream_profile clone(rs2_stream type, int index, rs2_format format) const
void init_matrices(const cv::Mat &ir_resized)
const std::string & get_failed_function() const
rs2::stream_profile _output_ir_profile