librealsense icon indicating copy to clipboard operation
librealsense copied to clipboard

WinRT originate error - While calling pipeline.start

Open zhuchen115 opened this issue 8 years ago • 13 comments

Required Info
Camera Model D415
Firmware Version 05.09.11.00
Operating System & Version Windows 10 1803
Platform PC
SDK Version 2. 11.1
Language C++
Windows SDK Version 10.0.17134.0
Compiler MSVC 19.14

Issue Description

The original code is like this:

#include <librealsense2/rs.hpp>
int main()
{
	using namespace rs2;
	pipeline pipe;
	config rscfg;
	rscfg.enable_stream(RS2_STREAM_COLOR, 1280, 720, RS2_FORMAT_BGR8, 30);
	rscfg.enable_stream(RS2_STREAM_INFRARED, 1280,720, RS2_FORMAT_Y8, 30);
	rscfg.enable_stream(RS2_STREAM_DEPTH, 1280, 720, RS2_FORMAT_Z16, 30);
	try {
		pipeline_profile selection = pipe.start(rscfg);
	        align rs_align = new align(RS2_STREAM_COLOR);
		pipe.stop();
	}
	catch (...)
	{
		return 1;
	}
        return 0;
}

The error happens when calling the pipe.start(rscfg) The error information is " WinRT originate error - 0xC00D36B3 : 'The stream number provided was invalid.'。"

After tracking the error, the exception is thrown by /src/win/win-uvc.cpp line 899. And there are no errors while running the realsense-viewer.

zhuchen115 avatar Jun 06 '18 01:06 zhuchen115

Just to clarify, you tried configuring the same set of streams in the Viewer (HD Depth+IR @ 30 + Color @ 30) and it worked without any errors?

dorodnic avatar Jun 06 '18 06:06 dorodnic

Yes. Actually, even if I removed the infrared and depth, the code still cannot work.

zhuchen115 avatar Jun 06 '18 07:06 zhuchen115

[Realsense Customer Engineering Team Comment] @zhuchen115 Looking at https://en.wikipedia.org/wiki/Windows_RT, it says : "Windows RT is a "discountinued" mobile operating system developed by Microsoft. So after internal discussion, we won't support WinRT at this time, can you let me know your usage and why you have to use WinRT?

No, I'm not using Windows RT, The operating system is Windows 10 desktop version.

zhuchen115 avatar Aug 30 '18 00:08 zhuchen115

Experiencing the exact same exception caused while calling pipe.start(cfg) using Windows 10 Enterprise Version 1709 OS Build 16299.611 in combination with both, D415 and D435 with FW 05.09.14.00 and SDK 2.15.0.

rs2::config cfg;
cfg.enable_all_streams();
_pipeProfile	= _pipe.start(cfg);

The error message is "WinRT originate error - 0xC00D36B3 : 'The stream number provided was invalid.'." but my device will works afterwards. However, want to get rid of all those exceptions.

jSoftSys avatar Aug 31 '18 13:08 jSoftSys

I have encountered the same problem. Differently, I was changing the configuration of the pipeline with UI (after pipe is started with some config). I am leaving working version of my code for future references. I hope it helps.

       // Create a shared pointer to a pipeline
	auto pipe = std::make_shared<rs2::pipeline>();
	auto c = std::make_shared<rs2::config>();
        pipe->start(*c);

pipeline (pipe.stop()) should be stopped , before resetting configuration and pipe.

alidemir1 avatar Sep 11 '18 08:09 alidemir1

Here is mine..

auto pipe = std::make_shared<rs2::pipeline>();
rs2::config cfg;
cfg.enable_stream(RS2_STREAM_COLOR, -1, 1280, 720, rs2_format::RS2_FORMAT_RGB8, 0);
cfg.enable_stream(RS2_STREAM_DEPTH, -1, 1280, 720, rs2_format::RS2_FORMAT_ANY, 0);

pipe->start(cfg);

The above works, but if I change the RS2_STREAM_DEPTH to RS2_FORMAT_Y8, I will get an abort() error.

ie THIS DOES NOT WORK!

auto pipe = std::make_shared<rs2::pipeline>();
rs2::config cfg;
cfg.enable_stream(RS2_STREAM_COLOR, -1, 1280, 720, rs2_format::RS2_FORMAT_RGB8, 0);
cfg.enable_stream(RS2_STREAM_DEPTH, -1, 1280, 720, rs2_format::RS2_FORMAT_Y8, 0);

pipe->start(cfg);

HippoEug avatar Oct 29 '18 06:10 HippoEug

[Realsense Customer Engineering Team Comment] To stream Y8 (luminance image), should configure the IR stream the depth stream not support the Y8 format

config.enable_stream(RS2_STREAM_INFRARED, 1, 1280, 720, RS2_FORMAT_Y8, 30);

Oops, my bad. Thanks for the clarification!

HippoEug avatar Oct 29 '18 07:10 HippoEug

So is there any solution to avoid this exception: "Exception thrown at 0x00007FFA7C645549 (KernelBase.dll) in im-show.exe: WinRT originate error - 0xC00D36B3 : 'The stream number provided was invalid.'"? I try to run 6 D435 with HW synchronization (they are connected to different USB). I check it with IR-streams, my code is following:

`

#include <librealsense2/rs.hpp> // Include RealSense Cross Platform API #include <opencv2/opencv.hpp> // Include OpenCV API #include <librealsense2/rs_advanced_mode.hpp> #include #include #include <string.h>

int main(int argc, char * argv[]) try { std::vectorstd::string serial_numbers; serial_numbers.resize(6); std::vectorrs2::pipeline pipelines; pipelines.resize(6);

rs2::context ctx;
std::size_t dev_id = 0;
int fps = 30;
int exposure = 2000;

for (auto&& dev : ctx.query_devices()) {
	std::cout << "Device (Thread) ID: " << std::to_string(dev_id) << std::endl;

	std::string serial = dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER);
	bool depth_found = true;
	rs2::sensor depth_sensor;
	if (serial.compare("827112070131") == 0 && depth_found) {
		std::cout << "Setting " << std::to_string(dev_id) << " to master!" << std::endl;
		
		rs2::pipeline pipe;
		rs2::config cfg;
		cfg.enable_device(serial);
		cfg.enable_stream(RS2_STREAM_INFRARED, 1, 1280, 720, RS2_FORMAT_Y8, fps);
		
		rs2::pipeline_profile profile = pipe.start(cfg);

		depth_sensor = profile.get_device().first<rs2::depth_sensor>();
		depth_sensor.set_option(RS2_OPTION_OUTPUT_TRIGGER_ENABLED, 1);
		depth_sensor.set_option(RS2_OPTION_INTER_CAM_SYNC_MODE, 1);
		depth_sensor.set_option(RS2_OPTION_EXPOSURE, exposure); // microseconds
		depth_sensor.set_option(RS2_OPTION_GAIN, 16);
		depth_sensor.set_option(RS2_OPTION_EMITTER_ENABLED, 0);

		std::ofstream intrinsicsfile;
		
		intrinsicsfile.open("0_intrinsics.txt");
		auto ir_stream = profile.get_stream(RS2_STREAM_INFRARED).as<rs2::video_stream_profile>();
		auto i = ir_stream.get_intrinsics();
		intrinsicsfile << std::setprecision(9) << ir_stream.width() << " " << ir_stream.height() << " " << i.ppx << " " << i.ppy << " " << i.fx << " " << i.fy << std::endl;
		intrinsicsfile.close();

		serial_numbers[0] = serial;
		pipelines[0] = pipe;
		auto tracking_camera_found = true;
		std::cout << "Tracking Camera ready!" << std::endl;
		dev_id++;

	}
	else if (serial.compare("819612071251") == 0 && depth_found) {
		std::cout << "Setting " << std::to_string(dev_id) << " to slave!" << std::endl;
		
		rs2::pipeline pipe;
		rs2::config cfg;
		cfg.enable_device(serial);
		cfg.enable_stream(RS2_STREAM_INFRARED, 1, 1280, 720, RS2_FORMAT_Y8, fps);
		
		rs2::pipeline_profile profile = pipe.start(cfg);

		depth_sensor = profile.get_device().first<rs2::depth_sensor>();
		depth_sensor.set_option(RS2_OPTION_INTER_CAM_SYNC_MODE, 2);
		depth_sensor.set_option(RS2_OPTION_EXPOSURE, exposure); // microseconds
		depth_sensor.set_option(RS2_OPTION_GAIN, 16);
		depth_sensor.set_option(RS2_OPTION_EMITTER_ENABLED, 0);

		std::ofstream intrinsicsfile;
		intrinsicsfile.open("1_intrinsics.txt");
		auto ir_stream = profile.get_stream(RS2_STREAM_INFRARED).as<rs2::video_stream_profile>();
		auto i = ir_stream.get_intrinsics();
		intrinsicsfile << std::setprecision(9) << ir_stream.width() << " " << ir_stream.height() << " " << i.ppx << " " << i.ppy << " " << i.fx << " " << i.fy << std::endl;
		intrinsicsfile.close();
		serial_numbers[1] = serial;
		pipelines[1]=pipe;
		std::cout << "Camera 1 ready!" << std::endl;
		dev_id++;
	}
	else if (serial.compare("819112072365") == 0 && depth_found) {
		std::cout << "Setting " << std::to_string(dev_id) << " to slave!" << std::endl;

		
		rs2::pipeline pipe;
		rs2::config cfg;
		cfg.enable_device(serial);
		cfg.enable_stream(RS2_STREAM_INFRARED, 1, 1280, 720, RS2_FORMAT_Y8, fps);
		//cfg.enable_stream(RS2_STREAM_COLOR, 848, 480, RS2_FORMAT_RGB8, 30);

		rs2::pipeline_profile profile = pipe.start(cfg);

		depth_sensor = profile.get_device().first<rs2::depth_sensor>();
		depth_sensor.set_option(RS2_OPTION_INTER_CAM_SYNC_MODE, 2);
		depth_sensor.set_option(RS2_OPTION_EXPOSURE, exposure); // microseconds
		depth_sensor.set_option(RS2_OPTION_GAIN, 16);
		depth_sensor.set_option(RS2_OPTION_EMITTER_ENABLED, 0);



		std::ofstream intrinsicsfile;
		intrinsicsfile.open("2_intrinsics.txt");
		auto ir_stream = profile.get_stream(RS2_STREAM_INFRARED).as<rs2::video_stream_profile>();
		auto i = ir_stream.get_intrinsics();
		intrinsicsfile << std::setprecision(9) << ir_stream.width() << " " << ir_stream.height() << " " << i.ppx << " " << i.ppy << " " << i.fx << " " << i.fy << std::endl;
		intrinsicsfile.close();
		serial_numbers[2] = serial;
		pipelines[2] = pipe;
		std::cout << "Camera 2 ready!" << std::endl;
		dev_id++;
	}
	else if (serial.compare("827112070114") == 0 && depth_found) {
		std::cout << "Setting " << std::to_string(dev_id) << " to slave!" << std::endl;

		rs2::pipeline pipe;
		rs2::config cfg;
		cfg.enable_device(serial);
		cfg.enable_stream(RS2_STREAM_INFRARED, 1, 1280, 720, RS2_FORMAT_Y8, fps);
		

		rs2::pipeline_profile profile = pipe.start(cfg);

		depth_sensor = profile.get_device().first<rs2::depth_sensor>();
		depth_sensor.set_option(RS2_OPTION_INTER_CAM_SYNC_MODE, 2);
		depth_sensor.set_option(RS2_OPTION_EXPOSURE, exposure); // microseconds
		depth_sensor.set_option(RS2_OPTION_GAIN, 16);
		depth_sensor.set_option(RS2_OPTION_EMITTER_ENABLED, 0);

		std::ofstream intrinsicsfile;
		intrinsicsfile.open("3_intrinsics.txt");
		auto ir_stream = profile.get_stream(RS2_STREAM_INFRARED).as<rs2::video_stream_profile>();
		auto i = ir_stream.get_intrinsics();
		intrinsicsfile << std::setprecision(9) << ir_stream.width() << " " << ir_stream.height() << " " << i.ppx << " " << i.ppy << " " << i.fx << " " << i.fy << std::endl;
		intrinsicsfile.close();
		serial_numbers[3] = serial;
		pipelines[3] = pipe;
		std::cout << "Camera 3 ready!" << std::endl;
		dev_id++;
	}
	else if (serial.compare("831612073787") == 0 && depth_found) {
	std::cout << "Setting " << std::to_string(dev_id) << " to slave!" << std::endl;


	rs2::pipeline pipe;
	rs2::config cfg;
	cfg.enable_device(serial);
	cfg.enable_stream(RS2_STREAM_INFRARED, 1, 1280, 720, RS2_FORMAT_Y8, fps);

	rs2::pipeline_profile profile = pipe.start(cfg);
	depth_sensor = profile.get_device().first<rs2::depth_sensor>();
	depth_sensor.set_option(RS2_OPTION_INTER_CAM_SYNC_MODE, 2);
	depth_sensor.set_option(RS2_OPTION_EXPOSURE, exposure); // microseconds
	depth_sensor.set_option(RS2_OPTION_GAIN, 16);
	depth_sensor.set_option(RS2_OPTION_EMITTER_ENABLED, 0);

	std::ofstream intrinsicsfile;
	intrinsicsfile.open("4_intrinsics.txt");
	auto ir_stream = profile.get_stream(RS2_STREAM_INFRARED).as<rs2::video_stream_profile>();
	auto i = ir_stream.get_intrinsics();
	intrinsicsfile << std::setprecision(9) << ir_stream.width() << " " << ir_stream.height() << " " << i.ppx << " " << i.ppy << " " << i.fx << " " << i.fy << std::endl;
	intrinsicsfile.close();
	serial_numbers[4] = serial;
	pipelines[4] = pipe;
	std::cout << "Camera 4 ready!" << std::endl;
	dev_id++;
	}
	else if (serial.compare("831612072101") == 0 && depth_found) {
	std::cout << "Setting " << std::to_string(dev_id) << " to slave!" << std::endl;

	

	rs2::pipeline pipe;
	rs2::config cfg;
	cfg.enable_device(serial);
	cfg.enable_stream(RS2_STREAM_INFRARED, 1, 1280, 720, RS2_FORMAT_Y8, fps);
	
	rs2::pipeline_profile profile = pipe.start(cfg);
	depth_sensor = profile.get_device().first<rs2::depth_sensor>();
	depth_sensor.set_option(RS2_OPTION_INTER_CAM_SYNC_MODE, 2);
	depth_sensor.set_option(RS2_OPTION_EXPOSURE, exposure); // microseconds
	depth_sensor.set_option(RS2_OPTION_GAIN, 16);
	depth_sensor.set_option(RS2_OPTION_EMITTER_ENABLED, 0);

	std::ofstream intrinsicsfile;
	intrinsicsfile.open("5_intrinsics.txt");
	auto ir_stream = profile.get_stream(RS2_STREAM_INFRARED).as<rs2::video_stream_profile>();
	auto i = ir_stream.get_intrinsics();
	intrinsicsfile << std::setprecision(9) << ir_stream.width() << " " << ir_stream.height() << " " << i.ppx << " " << i.ppy << " " << i.fx << " " << i.fy << std::endl;
	intrinsicsfile.close();
	serial_numbers[5] = serial;
	pipelines[5] = pipe;
	std::cout << "Camera 5 ready!" << std::endl;
	dev_id++;
	}
	else if (serial.compare("841612071164") == 0 && depth_found) {
	std::cout << "Setting " << std::to_string(dev_id) << " to slave!" << std::endl;

	rs2::pipeline pipe;
	rs2::config cfg;
	cfg.enable_device(serial);
	cfg.enable_stream(RS2_STREAM_INFRARED, 1, 1280, 720, RS2_FORMAT_Y8, fps);
	
	rs2::pipeline_profile profile = pipe.start(cfg);
	depth_sensor = profile.get_device().first<rs2::depth_sensor>();
	depth_sensor.set_option(RS2_OPTION_INTER_CAM_SYNC_MODE, 2);
	depth_sensor.set_option(RS2_OPTION_EXPOSURE, exposure); // microseconds
	depth_sensor.set_option(RS2_OPTION_GAIN, 16);
	depth_sensor.set_option(RS2_OPTION_EMITTER_ENABLED, 0);

	std::ofstream intrinsicsfile;
	intrinsicsfile.open("6_intrinsics.txt");
	auto ir_stream = profile.get_stream(RS2_STREAM_INFRARED).as<rs2::video_stream_profile>();
	auto i = ir_stream.get_intrinsics();
	intrinsicsfile << std::setprecision(9) << ir_stream.width() << " " << ir_stream.height() << " " << i.ppx << " " << i.ppy << " " << i.fx << " " << i.fy << std::endl;
	intrinsicsfile.close();
	serial_numbers[6] = serial;
	pipelines[6] = pipe;
	std::cout << "Camera 6 ready!" << std::endl;
	dev_id++;
	}
	else
		std::cout << "Unknown Serial number!" << std::endl;
}



std::vector<std::thread> threads;
for (int i = 0; i < serial_numbers.size(); ++i)
{
	rs2::pipeline pipe = pipelines[i];
	std::string serial = serial_numbers[i];
	threads.emplace_back([pipe, serial, i]() {
		
		const auto window_name = serial;
		cv::namedWindow(window_name, cv::WINDOW_AUTOSIZE);
		std::cout << "Thread " << std::to_string(i) << " opened!" << std::endl;
		int framenumber = 500;
		std::vector<cv::Mat> infrared_image;
		infrared_image.resize(framenumber);
		std::ofstream timestampfile;
		timestampfile.open(std::to_string(i) + "_" + serial + "time.txt");
		for (int frame_count = 0; frame_count < framenumber; ++frame_count) {
			rs2::frame infrared_frame;
			int w, h;
			cv::Mat cv_infrared_frame;
			rs2::frameset frames = pipe.wait_for_frames();
			infrared_frame = frames.get_infrared_frame();
			timestampfile << std::fixed << std::setprecision(1) << infrared_frame.get_timestamp() << std::endl;
			w = infrared_frame.as<rs2::video_frame>().get_width();
			h = infrared_frame.as<rs2::video_frame>().get_height();
			//Create OpenCV matrix of size (w,h) from the colorized depth data
			cv_infrared_frame = cv::Mat(cv::Size(w, h), CV_8U, (void*)infrared_frame.get_data(), cv::Mat::AUTO_STEP);
			cv_infrared_frame.copyTo(infrared_image[frame_count]);
			cv::imshow(window_name, infrared_image[frame_count]);
			cv::waitKey(1);
		}
		timestampfile.close();
		std::cout << "Replay" << std::endl;

		std::vector <int> compression_params;
		compression_params.push_back(CV_IMWRITE_PNG_COMPRESSION);
		compression_params.push_back(0);

		for (int frame_count = 0; frame_count < framenumber; ++frame_count) {
			cv::String filename_color = std::to_string(frame_count) + "_color_" + std::to_string(i) + ".png";//std::to_string(i) + "_" + 
			cv::imwrite(filename_color, infrared_image[frame_count], compression_params);//image_color_brg
			cv::imshow(window_name, infrared_image[frame_count]);
			cv::waitKey(1);

		}
	});
}
for (auto& t : threads) t.join(); // Must join / detach all threads
return EXIT_SUCCESS;

}

catch (const rs2::error & e) { std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << std::endl; return EXIT_FAILURE; } catch (const std::exception& e) { std::cerr << e.what() << std::endl; return EXIT_FAILURE; }`

At each call of 'rs2::pipeline_profile profile = pipe.start(cfg);' I get about 13 above mentioned exceptions. Is there any possibility to avoid it? I use Windows 10. The cameras are connected in a way that not more then 2 cameras are plugged in one USB-controller.

dzmitrykomar avatar Feb 26 '19 16:02 dzmitrykomar

I get this very error. Running the record playback SDK example without any changes whatsoever to the example code. Running win 10.

Exception thrown at 0x00007FF921FFA388 (KernelBase.dll) in playback-record.exe: WinRT originate error - 0xC00D36B3 : 'The stream number provided was invalid.'.

gunhaxxor avatar Apr 16 '19 10:04 gunhaxxor

It also crash in my program on win10. After added "Sleep(1000)" before pipe.start, it can run, but also throw "WinRT originate error - 0xC00D36B3". At least, it can run.

suntyruc avatar May 17 '19 07:05 suntyruc

This is related to my problem as well: https://github.com/IntelRealSense/librealsense/issues/4028

kartur avatar May 23 '19 08:05 kartur