I’m trying to get a depth image from the Orbbec Astra Pro. The Program stops at the line astra::Frame frame = reader.get_latest_frame();
Is this a source code problem or are there project dependencies which i don’t know?
I am using Visual Studio 2015 and copied and modified the example solution from the Astra SDK.
Here is a MWE:
#include <astra/astra.hpp>
#include "DepthCam.hpp"
#include <cstdio>
#include <iostream>
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
using namespace cv;
using namespace std;
Mat depthframe2mat(astra::DepthFrame depthframe)
{
int width = depthframe.width();
int height = depthframe.height();
int grayval = 0;
Mat image(height, width, CV_8UC1);
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
grayval = depthframe.data()[x+y*width] / (3500/256);
image.at<uchar>(y, x) = grayval;
}
}
return image;
}
int main(int argc, char** argv)
{
astra::initialize();
Mat depthimage;
astra::StreamSet streamSet;
astra::StreamReader reader = streamSet.create_reader();
reader.stream<astra::DepthStream>().start();
namedWindow("MyWindow", CV_WINDOW_AUTOSIZE);
do
{
astra::Frame frame = reader.get_latest_frame();
const auto depthFrame = frame.get<astra::DepthFrame>();
depthimage = depthframe2mat(depthFrame);
imshow("MyWindow", depthimage);
if(waitKey(30) >= 0) break;
} while (1);
astra::terminate();
return 0;
}
I am trying
to access simultaneously the depth and the Ir image. But I am experimenting a
crash, and I don’t know if I have configured the readers wright.
astra::Frame frame = readerD.get_latest_frame();
const auto depthFrame = frame.get<astra::DepthFrame>();
astra::Frame cFrame = readerC.get_latest_frame();
const auto colorFrame = cFrame.get<astra::ColorFrame>();
astra::Frame irFrame = readerIr.get_latest_frame();
const auto IrFrame = irFrame.get<astra::InfraredFrame16>();
I’m having this same problem right now.
I’ve tried all USB ports, and it still shows this error. I don’t know what to do, other than give up and use OpenNI2.
To solve this issue just copy the following files and folders from the bin* folder to your target folder: OpenNI2 (folder) Plugins (folder) OpenNI.ini OpenNI2.dll OpenNI2.lib
* The bin folder is where the precompiled samples exist after you unzip Astra SDK (AstraSDK-vX.X.X…/bin)