SimpleViewer: Couldn't find color stream:

Hello All,
I have an Astra Pro and I’m using OpenNi2 for it.

I’m trying to use the sample code. compiles perfectly with cmake and when I try to run it using ./SimpleViewer,

I’m unable to get any stream.

The error I’m getting is

"

After initialization:

Warning: USB events thread - failed to set priority. This might cause loss of data…
SimpleViewer: Couldn’t find color stream:
Device: Can’t find this source 2
Context: Couldn’t create stream from device:01cbc640, source: 2

SimpleViewer: No valid streams. Exiting

"

I understand that the colour camera is not streaming. I don’t know why.

It would be really appreciable if any one could help in solving this issue.

Thanks,
Prasanna

1 Like

@pkr97 , have you managed to resolve this issue? Have the same.

try again with sudo
ie. $ sudo ./SimpleViewer

if you’re on OSX you might need libusb to be installed here:
/usr/local/lib/libusb-1.0.0.dylib

@eduToolbox , sudo helps for “failed to set priority” warning, but does not fix the error “SimpleViewer: Couldn’t find color stream:”.

Hello,

Astra SDk or OpenNI, neither of them provides the driver for RGB camera of Astra Pro, You should modify the code and try to access using UVC camera driver. This will fail mostly with Astra SDk but should work with Openni.

Cheers,
Prasanna

1 Like

@alek & @pkr97

The following might be helpful:

here is a sample code for simultaneous stream of depth and colour streams using Astra SDK in Ubuntu 16.04
/*
#include <astra/astra.hpp>
#include <astra_core/astra_core.hpp>
#include
#include
#include <key_handler.h>
#include
#include
#include
#include
#include
#include <stdio.h>

#include “opencv2/opencv.hpp”
#include “opencv2/objdetect/objdetect.hpp”
#include “opencv2/highgui/highgui.hpp”
#include “opencv2/imgproc/imgproc.hpp”
#include <opencv2/core/core.hpp>
#include <opencv2/calib3d/calib3d.hpp>
*/
using namespace std;
using namespace cv;

/*
float elapsedMillis_{.0f};

using DurationType = std::chrono::milliseconds;
using ClockType = std::chrono::high_resolution_clock;

ClockType::time_point prev_;

using buffer_ptr = std::unique_ptr<astra::RgbPixel []>;
buffer_ptr buffer_;
unsigned int lastWidth_;
unsigned int lastHeight_;
*/

/*
astra::ColorStream configure_color(astra::StreamReader& reader)
{
auto colorStream = reader.streamastra::ColorStream();

auto oldMode = colorStream.mode();

//We don't have to set the mode to start the stream, but if you want to here is how:
astra::ImageStreamMode colorMode;

colorMode.set_width(640);
colorMode.set_height(480);
colorMode.set_pixel_format(astra_pixel_formats::ASTRA_PIXEL_FORMAT_RGB888);
colorMode.set_fps(30);

colorStream.set_mode(colorMode);

auto newMode = colorStream.mode();
printf("Changed color mode: %dx%d @ %d -> %dx%d @ %d\n",
    oldMode.width(), oldMode.height(), oldMode.fps(),
    newMode.width(), newMode.height(), newMode.fps());

return colorStream;

}

astra::DepthStream configure_depth(astra::StreamReader& reader)
{
auto depthStream = reader.streamastra::DepthStream();

auto oldMode = depthStream.mode();

//We don't have to set the mode to start the stream, but if you want to here is how:
astra::ImageStreamMode depthMode;

depthMode.set_width(640);
depthMode.set_height(480);
depthMode.set_pixel_format(astra_pixel_formats::ASTRA_PIXEL_FORMAT_DEPTH_MM);
depthMode.set_fps(30);

depthStream.set_mode(depthMode);

auto newMode = depthStream.mode();
printf("Changed depth mode: %dx%d @ %d -> %dx%d @ %d\n",
    oldMode.width(), oldMode.height(), oldMode.fps(),
    newMode.width(), newMode.height(), newMode.fps());

return depthStream;

}
*/

int main(int argc, char** argv)
{
astra::initialize();

set_key_handler();

astra::StreamSet streamSet;
astra::StreamReader reader = streamSet.create_reader();

reader.stream<astra::ColorStream>().start();  
reader.stream<astra::DepthStream>().start();

// may use for manual configuration of streams

/* auto colorStream = configure_color(reader);
auto depthStream = configure_depth(reader);

colorStream.start();
depthStream.start();*/

do
{
	astra::Frame frame = reader.get_latest_frame();
	const astra::ColorFrame colorFrame = frame.get<astra::ColorFrame>();
	
	const astra::DepthFrame depthFrame = frame.get<astra::DepthFrame>();
	
	cv::Mat mImageRGB(colorFrame.height(), colorFrame.width(), CV_8UC3, (void*)colorFrame.data());
	cv::Mat cImageBGR;
    cv::cvtColor( mImageRGB, cImageBGR, CV_RGB2BGR );
    
    cv::Mat mImageDepth(depthFrame.height(), depthFrame.width(), CV_16UC1, (void*)depthFrame.data());
	cv::Mat mScaledDepth;
    mImageDepth.convertTo( mScaledDepth, CV_8U, 255.0/3500 );

/*
cv::imshow( “Color Image”, cImageBGR ); // RGB image
cv::imshow( “Depth Image”, mScaledDepth ); // depth image
cv::imshow( “Depth Image 2”, mImageDepth ); // contains depth data
*/

/* std::cout << "colorStream – hFov: "
<< reader.streamastra::ColorStream().hFov()
<< " vFov: "
<< reader.streamastra::ColorStream().vFov()
<< std::endl;*/

/* std::cout << "depthStream – hFov: "
<< reader.streamastra::DepthStream().hFov()
<< " vFov: "
<< reader.streamastra::DepthStream().vFov()
<< std::endl;*/

/* check_fps();
*/

    astra_update();
    
    if( cv::waitKey(1) == 'q')
        break;

} while (shouldContinue);

astra::terminate();

}

I don’t know why basic c++ includes are not formatted accordingly but it can be managed easily.

cheers,
Prasanna

@pkr97 Dear sir, I wonder can this code be used for camera Astra? And what is missing include headers in your code?

nothing is missing I think. This can be used with Astra SDK and not relevant to camera. Sorry for late reply.

Prasanna