Can't convert Primitive image type to unit 8
1 view (last 30 days)
Show older comments
Hi i am using ip webcam app to get live stream video from my mobile phone to matlab and then try to find human by human-detector but i get following error while converting image to unit 8 my code is
url = 'http://192.168.1.9:8080/shot.jpg?timespam=';
ri = imread(url);
fh = image(ri);
while(1)
ri = imread(url);
f=image(ri);
% f=im2uint8(fh);
peopleDetector = vision.PeopleDetector('ClassificationModel' , 'UprightPeople_96x48', 'MergeDetections', true,'ClassificationThreshold' ,1.4);
BBOXES = step(peopleDetector,f);
result = insertObjectAnnotation(f,'rectangle', BBOXES, 'Human');
set(f,'CData',ri);
drawnow;
end
and i got following error
Error using PeopleDetector
Expected input number 2, I, to be one of these types:
uint8, uint16, double, single, int16
Instead its type was matlab.graphics.primitive.Image.
Error in vision.PeopleDetector/validateInputsImpl (line 340)
validateattributes(I,...
Error in camera (line 10)
BBOXES = step(peopleDetector,f);
0 Comments
Answers (2)
Adam
on 9 Mar 2016
Edited: Adam
on 9 Mar 2016
I don't know anything about what PeopleDetector is or where it comes from. Is it in a Mathworks toolbox? If so it would be useful to put it in the 'Products' list. I also can't make out easily exactly where in your code you are getting the error (please format code in a code { } block else it is largely unreadable).
However, ' matlab.graphics.primitive.Image' is a graphics object - i.e. the image that you actually see on the screen when you do an imshow or imagesc or image command. This is not what should be used for processing.
What should be used for processing is the raw data that you passed to the plotting command. In your case this would seem to be ri, subject to it needing to be converted to the correct data type, although your error message suggests that all common numeric types for images are supported.
Hazarding a guess without knowing what your object is:
BBOXES = step(peopleDetector,f);
looks like where you are going wrong as you are passing the graphics object to a function that is (I assume) a member of your peopleDetector object instead of passing raw data.
3 Comments
Adam
on 9 Mar 2016
Edited: Adam
on 9 Mar 2016
The problem is still that you are trying to pass a graphics image object though instead of the raw data. Where the data comes from should be independent of the processing done on it anyway. You just need to pass raw data to your function instead.
Try
BBOXES = step(peopleDetector,ri);
instead.
Walter Roberson
on 9 Mar 2016
peopleDetector = vision.PeopleDetector('ClassificationModel' , 'UprightPeople_96x48', 'MergeDetections', true,'ClassificationThreshold' ,1.4);
url = 'http://192.168.1.9:8080/shot.jpg?timespam=';
ri = imread(url);
fh = image(ri);
while(1)
ri = imread(url);
BBOXES = step(peopleDetector, ri);
result = insertObjectAnnotation(ri, 'rectangle', BBOXES, 'Human');
set(fh, 'CData', ri);
drawnow;
end
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!