feat(calib models): float change to ushort ,fix the T_mul_f number
This commit is contained in:
parent
0edf5fca65
commit
fbd416324e
|
@ -48,15 +48,14 @@ bool DepthProcessor::OnProcess(
|
||||||
ObjMat *output = Object::Cast<ObjMat>(out);
|
ObjMat *output = Object::Cast<ObjMat>(out);
|
||||||
int rows = input->value.rows;
|
int rows = input->value.rows;
|
||||||
int cols = input->value.cols;
|
int cols = input->value.cols;
|
||||||
std::cout << calib_infos_->T_mul_f << std::endl;
|
// std::cout << calib_infos_->T_mul_f << std::endl;
|
||||||
// 0.0793434
|
// 0.0793434
|
||||||
// TODO(MYNTEYE): Put the corresponding parameters(T,f)
|
cv::Mat depth_mat = cv::Mat::zeros(rows, cols, CV_16U);
|
||||||
cv::Mat depth_mat = cv::Mat::zeros(rows, cols, CV_32F);
|
|
||||||
for (int i = 0; i < rows; i++) {
|
for (int i = 0; i < rows; i++) {
|
||||||
for (int j = 0; j < cols; j++) {
|
for (int j = 0; j < cols; j++) {
|
||||||
float disparity_value = input->value.at<float>(i, j);
|
float disparity_value = input->value.at<float>(i, j);
|
||||||
float depth = calib_infos_->T_mul_f * 1000.0 / disparity_value ;
|
float depth = calib_infos_->T_mul_f / disparity_value;
|
||||||
depth_mat.at<float>(i, j) = depth;
|
depth_mat.at<ushort>(i, j) = depth * 1000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
output->value = depth_mat;
|
output->value = depth_mat;
|
||||||
|
|
|
@ -32,7 +32,7 @@ struct DepthTraits<uint16_t> {
|
||||||
static inline bool valid(uint16_t depth) { return depth != 0; }
|
static inline bool valid(uint16_t depth) { return depth != 0; }
|
||||||
static inline float toMeters(uint16_t depth) { return depth * 0.001f; } // originally mm
|
static inline float toMeters(uint16_t depth) { return depth * 0.001f; } // originally mm
|
||||||
static inline uint16_t fromMeters(float depth) { return (depth * 1000.0f) + 0.5f; }
|
static inline uint16_t fromMeters(float depth) { return (depth * 1000.0f) + 0.5f; }
|
||||||
static inline void initializeBuffer(std::vector<uint8_t>& buffer) {} // Do nothing - already zero-filled
|
static inline void initializeBuffer(std::vector<uint16_t>& buffer) {} // Do nothing - already zero-filled
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
@ -100,16 +100,15 @@ bool PointsProcessor::OnProcess(
|
||||||
for (int v = 0; v < height; ++v) {
|
for (int v = 0; v < height; ++v) {
|
||||||
cv::Vec3f *dptr = output->value.ptr<cv::Vec3f>(v);
|
cv::Vec3f *dptr = output->value.ptr<cv::Vec3f>(v);
|
||||||
for (int u = 0; u < width; ++u) {
|
for (int u = 0; u < width; ++u) {
|
||||||
float depth = input->value.at<float>(v, u);
|
float depth = input->value.at<uint16_t>(v, u);
|
||||||
|
|
||||||
// Missing points denoted by NaNs
|
// Missing points denoted by NaNs
|
||||||
if (!DepthTraits<float>::valid(depth)) {
|
if (!DepthTraits<uint16_t>::valid(depth)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
dptr[u][0] = (u - center_x) * depth * constant_x * 1000.0;
|
||||||
dptr[u][0] = (u - center_x) * depth * constant_x;
|
dptr[u][1] = (v - center_y) * depth * constant_y * 1000.0;
|
||||||
dptr[u][1] = (v - center_y) * depth * constant_y;
|
dptr[u][2] = depth * 1000.0;
|
||||||
dptr[u][2] = DepthTraits<float>::toMeters(depth);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,7 @@ void RectifyProcessor::stereoRectify(camodocal::CameraPtr leftOdo,
|
||||||
_pp[0][2] = cc_new[1].x;
|
_pp[0][2] = cc_new[1].x;
|
||||||
_pp[1][2] = cc_new[1].y;
|
_pp[1][2] = cc_new[1].y;
|
||||||
_pp[idx][3] = _t[idx]*fc_new; // baseline * focal length
|
_pp[idx][3] = _t[idx]*fc_new; // baseline * focal length
|
||||||
*T_mul_f = 0. - _t[idx];
|
*T_mul_f = 0. - _t[idx] * fc_new;
|
||||||
cvConvert(&pp, _P2);
|
cvConvert(&pp, _P2);
|
||||||
|
|
||||||
alpha = MIN(alpha, 1.);
|
alpha = MIN(alpha, 1.);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user