Batch conversion from mat file to pcd file
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hello. I have around 1800 mat file in the discontinous order like 1,2,4,7,8, etc. I already found a code to load all the mat file but I can not do the batch conversion from mat to pcd file. Can anyone help me with this? Thanks in advance!
채택된 답변
Walter Roberson
2022년 7월 18일
inputdir = 'Appropriate mat folder name goes here';
outputdir = 'Appropriate pcd folder name goes here';
if ~exist(inputdir, 'dir'); error('Input directory %s does not exist', inputdir); end
if ~exist(outputdir, 'dir'); mkdir(outputdir); end
dinfo = dir( fullfile(inputdir, '*.mat') );
filenames = fullfile({dinfo.folder}, {dinfo.name});
for K = 1 : length(filenames)
thisfile = filenames{K};
[~, basename, ~] = fileparts(thisfile);
outname = fullfile(outputdir, [basename '.pcd']);
Convert_mat_to_pcd(thisfile, outname);
end
Given appropriate code Convert_mat_to_pcd that uses the first parameter as the name of the input .mat file and uses the second parameter as the (fully qualified) output file name.
댓글 수: 7
Vu Minh
2022년 7월 19일
Thank you for your suggestion. However, when I replace the inputdir and outputdir with my two appropriate directory, the code ran into an error stating that Unrecognized function or variable 'Convert_mat_to_pcd'. This means I have to define the function Convert_mat_to_pcd before running the code right. Sorry for this because Im a very beginner.
I have no idea how to convert your mat files to pcd files. I do not the variables you have stored, or which portion of them need to be extracted, or which computations need to be done to create something that could potentially be written to a pcd file. I have no idea what the pcd file format is, and I do not know if any routines are available to write to pcd files.
The difficulty you outlined was in how to loop through the input files. The implication was that given any one mat file that you already know how to convert it to pcd. If so then write that logic into your own function Convert_mat_to_pcd
https://www.mathworks.com/help/vision/ref/pcwrite.html can write pcd files
Vu Minh
2022년 7월 19일
Yes I can convert 1 by 1 mat file to pcd as the code below:
A = importdata('save_220523_103750_pointcloud.mat');
xyzPoints = A.Location;
ptCloud = pointCloud(xyzPoints);
pcwrite(ptCloud,'save_220523_103750_pointcloud.pcd');
Walter Roberson
2022년 7월 19일
편집: Walter Roberson
2022년 7월 19일
function Convert_mat_to_pcd(matname, pcdname)
A = load(matname, 'Location');
xyzPoints = A.Location;
ptCloud = pointCloud(xyzPoints);
pcwrite(ptCloud, pcdname );
end
Vu Minh
2022년 7월 19일
Thank you sir for your valueable advice. I got this now. Anyway the function for loading mat file should be "importdata" instead of "load".
No, the function for loading mat files should be load(). importdata() has a lot of overhead and can return unexpected results.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
