imread Nvidia Jetson Nano not working

i'm trying to get my Jetson Nano to work with the MATLAB Coder Support Package for NVIDIA Jetson Package.
I installed all the prerequisites and succesfully connected with the Jetson Nano. I put an JPG-image(with putFile) into a folder and wrote following function:
function showPics(string1)
img1 = (imread(string1));
d = imageDisplay(hwJetson);
image(d,img1);
end
then i tried to compile that and build it on the jetson with these commands:
cfg = coder.config('exe');
cfg.TargetLang = 'C++';
cfg.Hardware = coder.hardware('NVIDIA Jetson');
cfg.Hardware.BuildDir = '~/Matlabtest';
cfg.CustomSource = fullfile('main.cpp');
codegen('-config',"cfg","showPics","-args",{"~/Matlabtest/left1.jpg"});
all i'm getting is the following error:
??? The function imread uses a precompiled shared library which is not supported on
the chosen target.
i took a look on the documentation (https://de.mathworks.com/help/matlab/ref/imread.html?searchHighlight=imread&s_tid=srchtitle_imread_1) and it says:
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
Usage notes and limitations:
  • Supports reading of 8-bit JPEG images only. The input argument filename must be a valid absolute path or relative path.
  • This function generates code that uses a precompiled, platform-specific shared library (Image Processing Toolbox).
there it must be possible to use imread with the Jetson... can't find anything on google. The application will use the attached webcams, but for now it's easier to develop with images already taken.
i tried the coder.CheckGpuInstall command, which passes all test. i get the following result:
Compatible GPU : PASSED (Warning: Support for GPU devices with Compute Capability 5.2 will be removed in a future MATLAB release. For more information on GPU support, see GPU Support by Release.)
CUDA Environment : PASSED
Runtime : PASSED
cuFFT : PASSED
cuSOLVER : PASSED
cuBLAS : PASSED
cuDNN
Environment : PASSED (Warning: Deep learning code generation has been tested with cuDNN v8.1. The provided cuDNN library v8.4 may not be fully compatible.)
Basic Code Generation : PASSED
Basic Code Execution : PASSED
ans =
struct with fields:
gpu: 1
cuda: 1
cudnn: 1
tensorrt: 0
basiccodegen: 1
basiccodeexec: 1
deepcodegen: 0
deepcodeexec: 0
tensorrtdatatype: 0
profiling: 0
I'm stuck for now and really appreciate all the help i can get :)

6 Comments

Hi Moritz,
You could use OpenCV to read the image on the Jetson. To integrate OpenCV with the code generation workflow, you would:
  1. Use coder.cinclude in your .m file to establish dependency on OpenCV headers.
  2. Use coder.ceval in your .m file to make calls to the OpenCV apis to read the image.
There is an example of such a workflow to generate code that reads an image on a raspberrypi:
If you open this example in MATLAB and go to the MATLAB function "raspi_fileRead_resnet.m" in the example directory, you will see a reference to a function called "readResizedImg". Open readResizedImg.m. This is an example you could follow of how lto make calls to OpenCV apis via coder.ceval.
Nathan
Hi Nathan,
thanks for the help :) that sounds really good. I'm going to try immediatly... but i'm still confused why it doesn't work with the MATLAB imread-command. As it is supposed to be supported for the Jetson according to the documentation.
I'll give an update as soon as i tried it.
Thanks
Hi Moritz,
The doc page for imread does indeed mention that it is supported for GPU codegen. But there are different types of codegen support. For imread GPU codegen, there is a note:
Functions that generate code that uses these precompiled libraries are only supported for codegen on platforms that can host MATLAB. So you could generate a MEX for a function using imread, but you wouldn't be able to generate standalone code for imread that you can deploy to your Jetson Nano. To do this, you'd need another option such as OpenCV.
Here is more info on the different types of codegen support:
Nathan
Hi Nathan,
thanks for the info. Now i understand. I finally was able to generate the code. It does not yet run on the Jetson(there seem to be a problem with the declaration of variables, but i think i'll fix that today).
I was asking myself, how to know which functions can be run on the Jetson and which can't. I found this list https://de.mathworks.com/help/referencelist.html?type=function&capability=codegen but i'm quite certain it's not the one i'm looking for. imread is mentioned there as supported. Do you have a better one?
EDIT:
Moritz
I kind of fixed the error. I just use the whole readResizedImage-Code and added:
hwobj = jetson;
d = imageDisplay(hwobj);
image(d,rgbImage);
The Code compiles & builds, then i run it on the Jetson via: runApplication, but nothing happening. No Window showing the Image pops up. I get the following in the Command Window
Code generation successful: View report
### Launching the executable on the target...
Executable launched successfully with process ID 15729.
Displaying the simple runtime log for the executable...
Note: For the complete log, run the following command in the MATLAB command window:
system(hwobj,'cat /home/flexybot/Matlabtest/MATLAB_ws/R2022a/C/Users/Moritz/Documents/Flexybot/Code/Matlab_Test/imreadOpenCV.log')
I Tried the liveCapture Example to see if there are any problems with the sdl-lib. It runs perfectly.
So, what did i do wrong? I again don't understand it...i attached the function in case that might help.
Would appreciate some help :)
Hi Moritz,
Did you manually run the application on the target? If not please run it manually, we will get to know if there are any compalints while running. You can also get the runtime log using the command shown in the above text
system(hwobj,'cat /home/flexybot/Matlabtest/MATLAB_ws/R2022a/C/Users/Moritz/Documents/Flexybot/Code/Matlab_Test/imreadOpenCV.log').
This will show if there are any issues while running the executable on the target.
Thanks,
Ramakrishna

Sign in to comment.

Answers (0)

Categories

Find more on Get Started with GPU Coder in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!