Error in deploying and generting C code this code in Jetson nano
2 ビュー (過去 30 日間)
古いコメントを表示
Hi
I have errors when deploying this code in jetson nano. However it is running fine in MATLAB script
function yolo2detectobject()
%#codegen
%Copyright 2020 - 2020 The MathWorks, Inc.
%Load the pre-trained car detection network
persistent yolov2Obj;
if isempty(yolov2Obj)
yolov2Obj = coder.loadDeepLearningNetwork('detectorYolo2.mat');
end
hwobj = jetson;
w = camera(hwobj,"vi-output, imx219 6-0010",[1280 720]);
d = imageDisplay(hwobj);
fps = 0;
avgfps = [];
cont = true;
while cont
% Capture the image from the webcam on hardware.
I = snapshot(w);
I=imresize(I,[224 224]);
Height=224;
Width=224;
Threshold = 0.2* (Height +Width);
% Run the detector on the input test image
tic;
[bboxes, scores, ~] = detect(yolov2Obj, I,'Threshold',0.22);
newt = toc;
% fps
fps = .9*fps + .1*(1/newt);
avgfps = [avgfps, fps]; %#ok<AGROW>
cars = size(bboxes, 1);
if car == 1
valColor = 0; % means we have one car so the color is green
elseif cars >= 2
valColor = findColor(bboxes,Threshold);
end
for ii = 1 : size(bboxes, 1)
if valColor(ii) == 0 % to find out number of boxes
showColor = [0 255 0]; % in case one car
else
showColor = [255 0 0]; % in case two cars or more
end
end
% Insert bounding box to test image
if isempty(scores) == 0
I = insertObjectAnnotation(I, 'rectangle', bboxes,scores, 'linewidth',3,'color',showColor);
% Display output on the target monitor
end
I = insertText(I , [1, 1], sprintf('FPS %2.2f', fps));
image(d, I);
end
end
function showColor = findColor(bboxes,Threshold)
% First index represents x value of starting top left point
% Second index represents y value of starting top left point
% Third index represent width of the bounding box
% Fourth index represent height of the bounding box
cars = size(bboxes, 1);
showColor = zeros(1,cars); % Default color green i.e. 0
% Loop through all car pairs and set color red i.e. 1 if < threshold
for i = 1:cars-1
for j = i+1:cars
p1 = bboxes(i,:);
p2 = bboxes(j,:);
x1 = p1(1) + p1(3)/2; % First x value
x2 = p2(1) + p2(3)/2; % Second x value
y1 = p1(2) + p1(4)/2; % First y value
y2 = p2(2) + p2(4)/2; % Second y value
% Calculating distance between the centres of these bounding boxes
dist = sqrt((x2 - x1)^2 + (y2 - y1)^2);
% Change threshold value from the top of the code
if dist < Threshold
showColor([i,j]) = 1;
end
end
end
end
and i got these errors while deploying
>> codegen('-config ', cfg,'yolo2detectobject', '-report');
??? Variable 'valColor' is not fully defined on some execution paths.
??? Variable ' showColor' is not fully defined on some execution paths.
Code generation failed
Kindly, looking for your support
0 件のコメント
回答 (1 件)
Sarvani Panguluri
2020 年 9 月 10 日
Hi,
A similar question has been answered here. You can also refer the documentation. I hope this will resolve your issue.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!