Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rs2_load_json() error #3696

Closed
TouchDeeper opened this issue Apr 7, 2019 · 6 comments
Closed

rs2_load_json() error #3696

TouchDeeper opened this issue Apr 7, 2019 · 6 comments

Comments

@TouchDeeper
Copy link


Required Info
Camera Model D435
Firmware Version 05.11.01.00
Operating System & Version Ubuntu 16.04
Kernel Version (Linux Only) 4.15.0
Platform PC
SDK Version 2.18.1
Language C++
Segment Robot

Issue Description

The core code is below:

    //load customized preset
    auto sensor2 = profile.get_device();
    std::string jsonPath = "./ShortRangePreset.json";
    auto advancedDepthSensor = sensor2.as<rs400::advanced_mode>();
    advancedDepthSensor.load_json(jsonPath);

The error is below:

RealSense error calling rs2_load_json(dev:0x14a9710, json_content:0x143af60, content_size:23):
    parse error - unexpected '.'

I read the related issue. It seems like has been fixed, but I encounter the error again.
Can you provide some advice? Thanks a lot!

@dorodnic
Copy link
Contributor

dorodnic commented Apr 8, 2019

Seems like the problem is in the JSON file content. Please check you are passing valid JSON file

@TouchDeeper
Copy link
Author

Hello @dorodnic
I check the json file, it is downloaded from the realsense wiki. I think the json file is no problem.
The error may caused by the load_json function, because when I modify the std::string jsonPath = "./ShortRangePreset.json"; to std::string jsonPath = "/ShortRangePreset.json";, the error will be:

RealSense error calling rs2_load_json(dev:0x14a9710, json_content:0x143af60, content_size:23):
    parse error - unexpected '/'

@dorodnic
Copy link
Contributor

dorodnic commented Apr 8, 2019

Oh... Sorry. Load JSON is expecting file content, not file name.

@TouchDeeper
Copy link
Author

Oh, so how can I load all the parameters of a .json file?

@dorodnic
Copy link
Contributor

std::ifstream file("ShortRangePreset.json");
std::string str((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
advanced.load_json(str);

@TouchDeeper
Copy link
Author

Hello @dorodnic
It works, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants