Loading file in MatLab - matlab

Attempting to follow this tutorial https://www.mathworks.com/help/vision/ref/objectdetectortrainingdata.html, I have aerial photos of parking lots in which I want cars to automatically be counted by the program. (If I am going in the wrong direction or there is an easier solution please let me know!).
My Error:
Warning: Variable 'carsGroundTruth' not found.
In carDetection (line 3)
My Code:
imageDir = fullfile(matlabroot, 'toolbox', 'vision', 'visiondata', 'carImages');
addpath(imageDir);
load('cars.mat','carsGroundTruth')
Why won't cars.mat load? I have tried putting it in the MATLAB file within Documents, and also the imageDir referenced in line 1.

Related

fatal error: itkMultiScaleHessianBasedMeasureImageFilter.h: No such file or directory #include "itkMultiScaleHessianBasedMeasureImageFilter.h"

I am trying to run the itkMultiScaleHessianBasedMeasureImageFilter program for blood vessels segmentation given in the below link
https://itk.org/ITKExamples/src/Nonunit/Review/SegmentBloodVesselsWithMultiScaleHessianBasedMeasure/Documentation.html
But I am getting the following error.
fatal error: itkMultiScaleHessianBasedMeasureImageFilter.h: No such file or directory
I am unable to understand that for Input, 2D slice/image should give or 3D image series of CT scan?
Also, I tried the code from
https://itk.org/ITKExamples/src/Filtering/ImageFeature/SegmentBloodVessels/Documentation.html
but this is also not working.
Can Someone please provide the solution?
With ITK 4.x and earlier, some of the classes were in Review module, which is turned off by default. That means you need to set CMake variable Module_ITKReview to ON when configuring/compiling ITK.

Reading files frame by frame

I have a folder containing .ply files. I want to read them and plot them like an animation. Initially i am trying to read the files and plot individually using the following code:
testfiledir = 'Files\';
plyfiles = dir(fullfile(testfiledir, '*.ply'));
for k=1:length(plyfiles)
FileNames = plyfiles(k).name;
plys=pcread(FileNames);
pcshow(plys)
end
But while running the script i get the error:
Error using pcread (line 51)
File "val0.ply" does not exist.
Error in read_pcd (line 6)
plys=pcread(FileNames);
val0.ply is one my first frame which is read in the variable 'plyfiles'
Where am I making mistake?
Use a datastore it is much easier and will keep track of everything for you. E.g.
ds = fileDatastore("Files/","ReadFcn",#pcread,"FileExtensions",".ply");
then you can read the files from it using read or readall, e.g.
while hasdata(ds)
plys = read(ds);
pcshow(plys)
end
It is slightly slower than if you can make the optimal implementation, but I prefer it big-time for its ease.

Unable to run code for DSP-SIFT in MATLAB

So, I got the code for DSP-SIFT from the original works of the author in the form of a toolbox. When I followed the instructions and tried to get it to run in MATLAB :
>> dsp_setup
>> dsp_mosaic
Undefined function 'vl_usift' for input arguments of type 'single'.
Error in vl_dspsift (line 50)
frames = vl_usift(im);
Error in dsp_mosaic (line 68)
[f1, d1] = vl_dspsift(im1g, opt);
After Googling this error(I am new to MATLAB), I found a solution saying that maybe my function cannot be recognised by MATLAB, so I need to add the containing folder to the MATLAB search path, which I tried doing:
>> which vl_usift -all
'vl_usift' not found.
>> addpath ('/home/dsp_toolbox_v0.0.2/dsp_toolbox_v0.0.2/toolbox/sift/')
Howver, I get the same error when trying to run the code.
I can add the code if it helps, but I do need advice on how to proceed from here.
Thanks
So, after a few hours of searching around, I finally came across the problem, there were a few lines commented in the setup file which I had to uncomment. Simple and frustrating.
Thanks!

error using save can't write file

I have got this really strange error in matlab. When I try to run the command
save(fullfile('filepath','filename'),'var','-v7');
I get the error message,
error using save can't write file
but when I try
save(fullfile('filepath','filename'),'var','-v7.3');
everything works fine. The the variable takes some space on the workspace, 165MB, but the I would guess that the size should not be an issue here. Does anyone know why it does not work to save in v7?
For the one that want to confirm the size of the variable, I will add the whos information,
Name Size Bytes Class Attributes
myName 1x1 173081921 struct
BR/ Patrik
EDIT
The variable I try to save is a struct with plenty of fields. I have tried to save a 3 dimensional matrix of size 800 mb, which went through without problems.
This is not an exact match to your problem, but I received the same error message when trying to save to -v6 format. Matlab is supposed to issue an error when a variable type or size is not supported:
help save
...
If any data items require features that the specified version does not support, MATLAB does not save those items and issues a warning. You cannot specify a version later than your version of MATLAB software.
Matlab's error checking seems to not be perfect, because there are certain situations (dependent on Matlab version and the particular variable type) that just fail all together with this not so helpful error message:
Error using save
Can't write file filename.mat.
For example, saving a string with certain unicode characters with the '-v6' option in Matlab r2015b in Linux produces the error, but Matlab r2016a in Windows does not. This is the output from my Matlab r2015b session:
>> A=char(double(65533))
A =
?
>> save('filename.mat','-v6','A')
Error using save
Can't write file filename.mat.
Without having your specific variable to test with, but seeing that the error messages match, I suggest removing parts of your data structure until it will save in order to isolate the variable that is causing it to fail.

how to connect or load file.dll to matlab?

I want through matlab tutorial but I did not understand it clearly.
Could anyone can explain to me step by step how to load and call .dll functions in matlab?
I tried to use loadlibrary function but I get and error, if anyone can tell we where to put the .dll file and the .h file?
I don't do this often, but i usually do something like:
fullpathToHeader = 'c:\full\path\to\a\header.h';
fullpathToDll = 'c:\full\path\to\a\libraty.dll';
loadlibrary(fullpathToDll, fullpathToHeader);
Then if that works, you can call library functions as:
[outArg1, outArg2, ...] = calllib('library','function',inArg1, inArg2, ...)
See the following link, which contains some problems I encountered and overcame, when trying to load a dll into matlab:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/341602