No appropriate method, property, or field 'snapshot' for class 'matlab.gr​aphics.pri​mitive.Ima​ge'.

I am trying to use my android camera for object recognition and not the laptop webcam because with a better camera the results should be better, but i get this error: No appropriate method, property, or field 'snapshot' for class 'matlab.graphics.primitive.Image'. The connection to andriod camera is done using Ip webcam program (for android). Here is the code i use for the connection.
%%
url = 'http://192.168.1.2:8080/shot.jpg';
ss = imread(url);
fh = image(ss);
% while true
% ss = imread(url);
% set(fh,'CData',ss);
% drawnow;
% end
% camera = webcam; % Connect to the camera
nnet = Net; % Load the neural net
while true
ss = imread(url);
set(fh,'CData',ss);
picture = fh.snapshot; % Take a picture
picture = imresize(picture,[227,227]); % Resize the picture
label = classify(nnet, picture); % Classify the picture
image(picture); % Show the picture
title(char(label)); % Show the label
drawnow;
end

4 Commenti

You declare fh to be an image and as the error says, image does not have a snapshot property, method or field, it is an image graphics object. I have no idea how linking to webcams for pictures works, but that is the reason you get that error message. What kind of object were you expecting to call snapshot on?
before trying to use android camera i was using this for webcamera: so i bealive that snapshot should use the variable i use to call the camera?
camera = webcam; % Connect to the camera
net = myNet; % Load the neural net
while true
picture = camera.snapshot; % Take a picture
picture = imresize(picture,[227,227]); % Resize the picture
label = classify(net, picture); % Classify the picture
image(picture); % Show the picture
title(char(label)); % Show the label
drawnow;
end
But there you call snapshot on a webcam object, which I guess does have a snapshot function. An image does not. You can probably just remove that line as you already have the image, you don't need to take a snapshot if you just start with a single image. although to resize it you will have to use
fh.CData
to get the actual image data rather than the image graphics object.
But i am not using a single image, i am trying to use the data from a live stream witch was possible with webcam

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su MATLAB Support Package for USB Webcams in Centro assistenza e File Exchange

Prodotti

Release

R2018b

Richiesto:

il 20 Feb 2019

Commentato:

il 20 Feb 2019

Community Treasure Hunt

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

Start Hunting!

Translated by