OpenNI 사용 가능 카메라 (특정 Orbbec Astra S)에서 깊이와 색상을 열 수있는 코드를 찾고/만들 수있었습니다. 표준 OpenNI 뷰어와 달리, 내 스트림은 가장 가까운 점을 가장 어둡게 표시하고 밝은 점으로 표시합니다.OpenNI 깊이 이미지 스왑 깊이 표시
카메라에 가장 가까운 점을 밝게 (흰색) 표시하고 멀리있는 부분을 어둡게 보이게하려면 어떻게 바꿀 수 있습니까?
#include "stdafx.h"
#include "OpenNI.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
// OpenCV Header
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/calib3d/calib3d.hpp>
using namespace std;
using namespace cv;
using namespace openni;
//Recorder
int main(int argc, char** argv)
{
Device device;
VideoStream DepthStream,ColorStream;
VideoFrameRef DepthFrameRead,ColorFrameRead;
const char* deviceURI = openni::ANY_DEVICE;
if (argc > 1)
{
deviceURI = argv[1];
}
Status result = STATUS_OK;
result = OpenNI::initialize();
result = device.open(deviceURI);
result = DepthStream.create(device, openni::SENSOR_DEPTH);
result = DepthStream.start();
result = ColorStream.create(device, openni::SENSOR_COLOR);
result = ColorStream.start();
device.setImageRegistrationMode(ImageRegistrationMode::IMAGE_REGISTRATION_DEPTH_TO_COLOR);
int framenum = 0;
Mat frame;
while (true)
{
if (DepthStream.readFrame(&DepthFrameRead) == STATUS_OK)
{
cv::Mat cDepthImg(DepthFrameRead.getHeight(), DepthFrameRead.getWidth(),
CV_16UC1, (void*)DepthFrameRead.getData());
cv::Mat c8BitDepth;
cDepthImg.convertTo(c8BitDepth, CV_8U, 255.0/(8000));
cv::imshow("Orbbec", c8BitDepth);
}
if (ColorStream.readFrame(&ColorFrameRead) == STATUS_OK)
{
ColorStream.readFrame(&ColorFrameRead);
const openni::RGB888Pixel* imageBuffer = (const openni::RGB888Pixel*)ColorFrameRead.getData();
frame.create(ColorFrameRead.getHeight(), ColorFrameRead.getWidth(), CV_8UC3);
memcpy(frame.data, imageBuffer, 3 * ColorFrameRead.getHeight()*ColorFrameRead.getWidth() * sizeof(uint8_t));
cv::cvtColor(frame, frame, CV_BGR2RGB); //this will put colors right
cv::imshow("frame", frame);
framenum++;
}
if (cvWaitKey(30) >= 0)
{
break;
}
}
DepthStream.destroy();
ColorStream.destroy();
device.close();
OpenNI::shutdown();
return 0;
}
------------------- 편집 -------------------
이 이미지는 원래 (그것이 얼마나 어두운 주)과 같이 16 비트 이미지로 읽습니다 :
다음과 같이 그러나 8 비트 이미지로 변환 한 후, 그들이 보게 :
캡처 한 깊이 이미지 예제를 몇 가지 제공 할 수 있습니까? – masad
@masad는 위 사진을 추가했습니다. 손이 검은 색이 아니며 작동 거리 내에 있음을 유의하십시오.그러나 가까이 있기 때문에 배경 벽보다 훨씬 더 어둡게 표현됩니다. –