Error executing command touch -c code generation

3 次查看(过去 30 天)
Any idea how can I fix this error?
codegen('-config ',cfg,'-args',inputArgs,'alisamehtrial','-report');
------------------------------------------------------------------------
Error executing command "touch -c Timo/MATLAB_ws/R2023a/E/JetsonWork/georgee/codegen/exe/alisamehtrial/*.*;make -f alisamehtrial_rtw.mk -j4 all MATLAB_WORKSPACE="timo/MATLAB_ws/R2023a" LINUX_TARGET_LIBS_MACRO="" -C Timo/MATLAB_ws/R2023a/E/JetsonWork/georgee/codegen/exe/alisamehtrial". Details:
STDERR: make: alisamehtrial_rtw.mk: No such file or directory
make: *** No rule to make target 'alisamehtrial_rtw.mk'. Stop.
STDOUT: make: Entering directory '/home/ahmedtamer/Timo/MATLAB_ws/R2023a/E/JetsonWork/georgee/codegen/exe/alisamehtrial'
make: Leaving directory '/home/ahmedtamer/Timo/MATLAB_ws/R2023a/E/JetsonWork/georgee/codegen/exe/alisamehtrial'
------------------------------------------------------------------------
Build error: C++ compiler produced errors. See the Build Log for further details.
More information
Code generation failed: View Error Report
Error using codegen
>>
I get this error when I try to deploy a code from matlab to jetson nano
This is my code:
function alisamehtrial(mdlName,calibFile,port,cameraName,resolution)
%#codegen
hwobj = jetson()
%%
% Create hwobj
hwobj = jetson();
camObj = camera(hwobj,cameraName,resolution);
dispObj = imageDisplay(hwobj);
obj = velodynelidar(hwobj,mdlName,calibFile,'Port',2368);
%%
R = [102.3 0 -178.5 ];
Translation = [-0.19 -0.32 0.08];
tform1 = rigidtform3d(R, Translation);
camToLidar = invert(tform1);
LidarToCam = tform1;
focalLength = [2.030730245970483e+03 2.028918613870282e+03];
principalPoint = [1.372086996058644e+03 7.403715833893430e+02];
imageSize = [720 1280];
intrinsics = cameraIntrinsics(focalLength,principalPoint,imageSize);
persistent yolov4Obj;
if isempty(yolov4Obj)
yolov4Obj = coder.loadDeepLearningNetwork('tinyyolov4coco.mat');
end
%%
continousStreaming = true;
%%
start(obj)
if strcmp(mdlName,'VLP16')
lenOut = 120;
outStructLen = 28000;
else
lenOut = 70;
outStructLen = 48000;
end
%%
while continousStreaming
% Capture the image from the Jetson camera hardware.
I = snapshot(camObj);
pc = read(obj);
M=16;
N=1808;
reshapedLocation = reshape(pc.Location, [M, N, 3]);
outStruct = pointCloud(reshapedLocation);
% Call to detect method
[bboxes, scores, labels] = detect(yolov4Obj, I, 'Threshold', 0.3);
personIndices = find(labels == 'person');
personBboxes = bboxes(personIndices, :);
personScores = scores(personIndices, :);
personLabels = labels(personIndices, :);
% Convert categorical labels to cell array of character vectors
labels = cellstr(labels);
% Annotate detections in the camera image.
img = insertObjectAnnotation(I, 'rectangle', bboxes, labels);
% Remove ground plane
groundPtsIndex = segmentGroundFromLidarData(outStruct, 'ElevationAngleDelta', 5, ...
'InitialElevationAngle', 0);
nonGroundPts = select(outStruct, ~groundPtsIndex);
% Process lidar data if there are detections
if bboxes == personBboxes
[lidarBbox, ~, boxUsed] = bboxCameraToLidar(bboxes, nonGroundPts, intrinsics, ...
camToLidar, 'ClusterThreshold', 0.3, 'MaxDetectionRange', [1, 50]);
[distance, nearestRect, idx] = helperComputeDistance(bboxes, nonGroundPts, lidarBbox, ...
intrinsics, LidarToCam);
% Print distance information
fprintf('Distance of a Person');
else
[lidarBbox, ~, boxUsed] = bboxCameraToLidar(bboxes, nonGroundPts, intrinsics, ...
camToLidar, 'ClusterThreshold', 0.3, 'MaxDetectionRange', [1, 50]);
[distance, nearestRect, idx] = helperComputeDistance(bboxes, nonGroundPts, lidarBbox, ...
intrinsics, LidarToCam);
% Print distance information
%fprintf('Distance of an Object');
% Update image with bounding boxes
% im = updateImage(display, im, nearestRect, distance);
% updateLidarBbox(display, lidarBbox)
end
end
end
%%
function [distance, nearestRect, index] = helperComputeDistance(bboxes, outStruct, lidarBbox, intrinsic, lidarToCam)
idx = zeros(0,1);
numLidarDetections = size(lidarBbox, 1);
nearestRect = zeros(0, 4);
distance = zeros(1, numLidarDetections);
index = zeros(0, 1);
for i = 1:numLidarDetections
bboxCuboid = lidarBbox(i, :);
% Create cuboidModel
model = cuboidModel(bboxCuboid);
% Find points inside cuboid
ind = findPointsInsideCuboid(model, outStruct);
pts = select(outStruct, ind);
% Project cuboid points to image
imPts = projectLidarPointsOnImage(pts, intrinsic, lidarToCam);
% Find 2-D rectangle corresponding to 3-D bounding box
[nearestRect(i, :), idx] = findNearestRectangle(imPts, bboxes);
% Limit the index to 10000
idx = min(idx, 10000);
index = [index; idx];
% Calculate the median or mean distance from lidar points
distances = sqrt(sum(pts.Location.^2, 2)); % Euclidean distance
% Limit the detection distance to 10000
distances = distances(distances <= 10000);
if ~isempty(distances)
distance(i) = mean(distances); % Use median or mean depending on your preference
else
distance(i) = NaN; % or any other value to indicate no valid distance within the range
end
end
end
function [nearestRect, idx] = findNearestRectangle(imPts, bboxes)
numBbox = size(bboxes, 1);
ratio = zeros(numBbox, 1);
% Iterate over all the rectangles
for i = 1:numBbox
bbox = bboxes(i, :);
corners = getCornersFromBbox(bbox);
% Find overlapping ratio of the projected points and the rectangle
idx = (imPts(:, 1) > corners(1, 1)) & (imPts(:, 1) < corners(2, 1)) & ...
(imPts(:, 2) > corners(1, 2)) & (imPts(:, 2) < corners(3, 1));
ratio(i) = sum(idx);
end
% Get nearest rectangle
[~, idx] = max(ratio);
nearestRect = bboxes(idx, :);
end
function cornersCamera = getCornersFromBbox(bbox)
cornersCamera = zeros(4, 2);
cornersCamera(1, 1:2) = bbox(1:2);
cornersCamera(2, 1:2) = bbox(1:2) + [bbox(3), 0];
cornersCamera(3, 1:2) = bbox(1:2) + bbox(3:4);
cornersCamera(4, 1:2) = bbox(1:2) + [0,bbox(4)];
end
  1 个评论
Ramakrishna Mandalapu
编辑:Ramakrishna Mandalapu 2023-12-20
Hi Ahmed,
Make sure your codegen config is set up correctly for 'NVIDIA Jetson'. Add the following line to your codegen config:
cfg.Hardware = coder.hardware('NVIDIA Jetson');
cfg.Hardware.BuildDir = '~/timo';
From the error log, it seems the path might be inaccessible, as 'Timo/MATLAB_ws/R2023a/E/JetsonWork/....' may not exist on the target. Check the 'BuildDir' option in the hardware object above. As indicated in the code, the build directory will be created in the home directory. Ensure that the specified path is correct, either by providing the complete path like '/home/Timo/timo' or using aliases for home like '~/timo'. Configure 'BuildDir' in the hardware config accordingly and retry the build.
Ramakrishna

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by