unexpected figure with inverted child photo pops up when i run my code

43 vues (au cours des 30 derniers jours)
Ayesha ayub
Ayesha ayub le 14 Sep 2014
Modifié(e) : David Young le 23 Sep 2014
i'm trying to count people in a video but i dont want to display the video .the code works fine but every time i run the code a figure pops up. i have no idea why can some one help me
here's my code:
mov = mmreader('SampleVideo.avi'); for i=1:mov.NumberOfFrames img = read(mov,i); th = graythresh(image);
binaryImage = im2bw(image,th); cc = bwconncomp(binaryImage,4); number_of_people= cc.NumObjects; end display(number_of_people )
  1 commentaire
David Young
David Young le 23 Sep 2014
Please format your code by putting two spaces at the start of each line.

Connectez-vous pour commenter.

Réponses (2)

Image Analyst
Image Analyst le 14 Sep 2014
but I don't really know since the deprecated function mmreader has finally been removed by R2014a and so I can't run it. Why don't you use one of the function that they've been recommending to replace it, such as VideoReader?
  1 commentaire
Ayesha ayub
Ayesha ayub le 23 Sep 2014
Modifié(e) : Ayesha ayub le 23 Sep 2014
videoread wont work on my MATLAB version rb2009 how can i remove it

Connectez-vous pour commenter.


David Young
David Young le 23 Sep 2014
Modifié(e) : David Young le 23 Sep 2014
It's because you are assigning a value to img but using the value of image, which has the side effect of displaying the boy.
Replace
th = graythresh(image);
with
th = graythresh(img);
and likewise wherever you use image, to make your code consistent.

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by