LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

compare two jpeg's taken from ip camera

Solved!
Go to solution

Hi folks,

 

I've got an IP camera, and I need to take two photos and compare them, and then my program must return if there's something different on the image. Taking the photos is not a problem, using an activex control with the camera library I can use a function that writes a jpeg image to the disk. The real problem is to compare those images. I tried to subtract them, but since the sensor is a CMOS, there's a lot of noise, and even if i take two photos without moving anything, when i subtract the pictures it is not empty (black).Then I tried using Vision Assistent or the Golden Template, but I could not use them, because of two problems:

- first, most of the functions on Vision Assistent can only process 8 bit binary images. Does someone know how to convert a jpeg to this format?

- second, when i tried to open images to use the IMAQ functions on my own vi, i used the IMAQ image.ctl and typed the path to the pictures, and connected them to the functions, but everytime i run thid kind of VI, it returns an error saying that the file is not an image.

 

If you know how to solve one of these issues, or if you think of another method to compare the jpeg's, please let me know!

 

 

Regards,

Vitor

0 Kudos
Message 1 of 19
(5,753 Views)

I forgot to post some of the images i need to compare:

 

imagem1.jpgimagem2.jpgimagem3.jpg

 Image 1                                                                         Image 2                                                                 Image 1 - Image 2

 

When i compare image 1 and image 2, my VI must return nothing, but if the cup isn't there on image 2, it must return a warning.

What i did was to deploy the images in 2D arrays, subtract them, and if the result was different from 0 the VI returns the warning, but even when the images are "equal", the subtraction is different from zero.

Any ideas? 

 

0 Kudos
Message 2 of 19
(5,750 Views)

Are you using IMAQ ReadFile VI?

0 Kudos
Message 3 of 19
(5,746 Views)

I haven't worked too extensively with vision and have limited experience. Under the "Graphics and Sounds" palate there are VIs that can read JPEG files. I am not sure if you can pass these images into the Vision VIs. I don't have Vision installed on my machine at the moment to help with the Vision specific questions that you have.

 

As you found out I don't think simply subtracting the images will work for you. I think you will need to isolate color planes and then check how much of your specified color is in the image. Even here you cannot simply subtract the images. You will probably have to look for the percentage of your desired color and compare that number between the two images. You should use some tolerance since you will not get exact matches.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 19
(5,744 Views)

Hello,

 

"substract is not the way"

 

yes and no, it depend of the  functionnality  expected 

 

Could you post a jpg of the code showin how it open the file an how you substract images

 

 

regards

 

Tinnitus

 

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 5 of 19
(5,712 Views)
Solution
Accepted by topic author Vitor Soares

Hi. Here is the solution. Just set some level for similarity (example 1%) and use this VI. Take care.

Similar

Different

VI snippet

Message 6 of 19
(5,646 Views)

Is there a way of doing the same but with LabWindows CVI?

0 Kudos
Message 7 of 19
(5,543 Views)

can you send to me your compare images program??? please

 

thanks

0 Kudos
Message 8 of 19
(5,413 Views)

You can simply drag and drop the VI snippet (image with block diagram) to your VI in LabVIEW.

0 Kudos
Message 9 of 19
(5,403 Views)

I'm sorry, i dont understand what you said.

 

I try drop the image to labview (block diagram), but it's not possible.

 

can you help me again??

 

thanks

0 Kudos
Message 10 of 19
(5,395 Views)