feat(depth_processor.cc): implement Onprocess

This commit is contained in:
kalman 2019-01-09 14:22:11 +08:00
parent eea273b0db
commit 9a7e420c3a

View File

@ -41,13 +41,23 @@ Object *DepthProcessor::OnCreateOutput() {
bool DepthProcessor::OnProcess( bool DepthProcessor::OnProcess(
Object *const in, Object *const out, Processor *const parent) { Object *const in, Object *const out, Processor *const parent) {
MYNTEYE_UNUSED(parent) MYNTEYE_UNUSED(parent)
// const ObjMat *input = Object::Cast<ObjMat>(in); const ObjMat *input = Object::Cast<ObjMat>(in);
// ObjMat *output = Object::Cast<ObjMat>(out); ObjMat *output = Object::Cast<ObjMat>(out);
// cv::Mat channels[3 /*input->value.channels()*/]; int rows = input->value.rows;
// cv::split(input->value, channels); int cols = input->value.cols;
// channels[2].convertTo(output->value, CV_16UC1); float T = 0.08;
// output->id = input->id; float f = 0.01;
// output->data = input->data; cv::Mat depth_mat = cv::Mat::zeros(rows, cols, CV_32F);
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
float disparity_value = input->value.at<float>(i, j);
float depth = T * f / disparity_value;
depth_mat.at<float>(i, j) = depth;
}
}
output->value = depth_mat;
output->id = input->id;
output->data = input->data;
return true; return true;
} }