Welcome new user! You can search existing questions and answers without registering, but please register to post new questions and receive answers.
Welcome to JeVois Tech Zone, where you can ask questions and receive answers from other members of the community.

Relative and absolute path in jevois sd card for reading files?

0 votes
I am programming c++. I want to read the contents of a yaml file into my program. If I'm using the following function,

cv::FileStorage fs("file.yaml", cv::FileStorage::READ);

What should I replace "file.yaml" with in order to read file.yaml from either:

a) The directory my .so file is in

b) Another location on the JeVois SD card.

How would I do this with a relative path name, and an absolute path name? Would it be correct to assume that I can use "/Modules/[Vendor]/[Module_name]/file.yaml"?

Thank you for your help.
asked May 9 in Programmer Questions by unswniarc (360 points)

1 Answer

+1 vote
 
Best answer

The recommended way is to use the absolutePath() function provided by jevois::Component (available in Module since Module inherits from Component):

http://jevois.org/doc/classjevois_1_1Component.html

In you case, use

cv::FileStorage fs(absolutePath("file.yaml"), cv::FileStorage::READ);
 

to get file.yaml from inside the module's path (/jevois/modules/Vendor/ModuleName/file.yaml)

You may also want to use some macros defined in Config.H of jevois. Please check out ~/jevois/include/jevois/Config.H.in

then two versions are created by CMake, one in hbuild/ and the other in pbuild/. Config.H is finally auto-included by every file that is compiled by our CMake scripts. So you can use any of the definitions in there, and their mappings will be correct for either host or platform. For example, JEVOIS_ROOT_PATH, JEVOIS_ENGINE_INITSCRIPT or JEVOIS_SHARE_PATH, etc

answered May 9 by JeVois (28,180 points)
selected May 10 by unswniarc
...