Page 4 of 4

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-29T20:19:22-07:00
by vpmammana
Note that you previously suggested to substitute "compare" by "convert -compose difference"

Code: Select all

convert r1.png r2.png -compose difference -composite s1.png
But in this case, I am not able to use -metric AE, which is important for me.

If I include -metric to the convert command, it doesn't show the numerical indication of how different are the images.

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-29T20:50:00-07:00
by vpmammana
A quick test I just did:

If I add -fuzz 8% to compare, as follows:

Code: Select all

compare -fuzz 5% -metric AE r1.png r2.png s1.png 
the result is that I get "zero" as a numerical indication of how close the images are (the images are almost identical). But this seems a bit artificial for me... Isn't there a way to get the numerical indication from "convert -compose differences" without "fuzzing" the image? Note that the "fuzz" was added because of the "squared" features typically present on JPG images.

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-30T01:00:58-07:00
by fmw42
It means that <=5% of the pixels in your image are different, so that if you ignore 5% they will be the same in counts.

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-30T20:27:37-07:00
by snibgo
vpmammana wrote:I am still facing issues related to the "lossy" characteristic of "jpg" images.
When an image is saved as JPG, information is lost. Converting it to another format won't get the information back.

But information is lost every time a JPG is created. So your image-processing should never write to JPG files (unless you really have to).

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2016-01-02T08:57:00-07:00
by vpmammana
You are right. I understand perfectly that.

However, JPG is the way these D-Link cameras save their images. So I need to find some way to deal with the information I have within the jpg format.

Right now I am using the -fuzz filter. I wonder if there could be something better?

Moreover, now I am facing another issue with convert when I try to -verbose to the screen:

Code: Select all

convert r1.png r2.png r3.png -verbose -evaluate-sequence Mean  average.png
The -verbose option causes a message to the screen such as:

Code: Select all

/home/dir/r1.png=>/home/dir/average.png PNG 320x240 320x240+0+0 8-bit sRGB 115KB 0.000u 0:00.000
I wonder if it is really processing all images or somehow disregarding r2.png and r3.png images?

Is it a bug at the -verbose option, or do I have a problem with my files?

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2016-01-02T10:34:54-07:00
by snibgo
IM processes commands in the order they are given (mostly). "-verbose" gives information about what happens after it is given. Put it at the start if you want to know about the reads.

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2016-01-02T13:29:09-07:00
by vpmammana
Ok...

I will check that.

Now I am facing another issue:

When I do the following in PHP, $compara is null:

Code: Select all

$compara=shell_exec("compare -fuzz 5% -metric AE /home/".$key."/".$dir[$key]."/".$average." ".$imagem_atual." s_".$key."_".date("Y_m_d-H_i_s").".png");
How could I get the average value that is shown in the screen into my PHP code? Note that I am refering to the to the integer value. I am not interested on the PNG image.

I also tried "exec".... I am not that experienced on PHP... Using IM within PHP is a pain... It would be much more convenient to use it with shell for the type of application I am generating.

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2016-01-02T14:03:07-07:00
by fmw42
Not sure what you are trying to do here functionally. But compare writes to standard error so you need the following syntax. I do not see null: listed above and I do not know why you have .png at the end! Where do you output the value of compara?

Code: Select all

compare -fuzz 5% -metric AE image1.png image2.png null: 2>&1
Always test on fixed image names, before using variables!

Try

Code: Select all

<?php
exec("/path2/compare -fuzz 5% -metric AE image1.png image2.png null: 2>&1",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2016-01-02T14:06:26-07:00
by vpmammana
Ok! thank you for your patience!

Actually I also want the *.png output.

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2016-01-02T15:14:21-07:00
by fmw42
You cannot have just .png for the output. It has to have a file name. So 3 images must be listed in the command.


<?php
exec("/path2/compare -fuzz 5% -metric AE image1.png image2.png result.png 2>&1",$out,$returnval);
foreach($out as $text)
{echo "$text<br>";}
?>

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2016-01-02T15:38:19-07:00
by vpmammana
ok... I got it.

It is working, man! I am pretty much there... I will share what I got here later...