#include <iostream>
{
if(!obsensorCapture.isOpened()){
std::cerr << "Failed to open obsensor capture! Index out of range or no response from device";
return -1;
}
std::cout << "obsensor camera intrinsic params: fx=" << fx << ", fy=" << fy << ", cx=" << cx << ", cy=" << cy << std::endl;
const double minVal = 300;
const double maxVal = 5000;
while (true)
{
if (obsensorCapture.grab())
{
{
}
{
depthMap.
convertTo(adjDepthMap,
CV_8U, 255.0 / (maxVal - minVal), -minVal * 255.0 / (maxVal - minVal));
}
static const float alpha = 0.6f;
{
depthMap.
convertTo(adjDepthMap,
CV_8U, 255.0 / (maxVal - minVal), -minVal * 255.0 / (maxVal - minVal));
for (
int i = 0; i < image.
rows; i++)
{
for (
int j = 0; j < image.
cols; j++)
{
uint8_t depthValue = 255 - adjDepthMap.
at<uint8_t>(i, j);
if (depthValue != 0 && depthValue != 255)
{
outRgb[0] = (uint8_t)(outRgb[0] * (1.0f - alpha) + depthValue * alpha);
outRgb[1] = (uint8_t)(outRgb[1] * (1.0f - alpha) + depthValue * alpha);
outRgb[2] = (uint8_t)(outRgb[2] * (1.0f - alpha) + depthValue * alpha);
}
}
}
imshow(
"DepthToColor", image);
}
}
break;
}
return 0;
}
n-dimensional dense array class
Definition mat.hpp:830
_Tp & at(int i0=0)
Returns a reference to the specified array element.
int cols
Definition mat.hpp:2165
bool empty() const
Returns true if the array has no elements.
int rows
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions
Definition mat.hpp:2165
void convertTo(OutputArray m, int rtype, double alpha=1, double beta=0) const
Converts an array to another data type with optional scaling.
void release()
Decrements the reference counter and deallocates the matrix if needed.
Size2i Size
Definition types.hpp:370
Vec< uchar, 3 > Vec3b
Definition matx.hpp:441
#define CV_8U
Definition interface.h:73
@ COLORMAP_JET
Definition imgproc.hpp:4528
@ CAP_OBSENSOR
For Orbbec 3D-Sensor device/module (Astra+, Femto, Astra2, Gemini2, Gemini2L, Gemini2XL,...
Definition videoio.hpp:131
@ CAP_PROP_OBSENSOR_INTRINSIC_FY
Definition videoio.hpp:713
@ CAP_PROP_OBSENSOR_INTRINSIC_CX
Definition videoio.hpp:714
@ CAP_PROP_OBSENSOR_INTRINSIC_CY
Definition videoio.hpp:715
@ CAP_PROP_OBSENSOR_INTRINSIC_FX
Definition videoio.hpp:712
@ CAP_OBSENSOR_BGR_IMAGE
Data given from BGR stream generator.
Definition videoio.hpp:697
@ CAP_OBSENSOR_DEPTH_MAP
Depth values in mm (CV_16UC1).
Definition videoio.hpp:696