I require an experienced PHP programmer to improve the attached image comparison function. Currently it's working okay but quite slow.
The input is a new jpeg image (in a buffer) and a reference to the previous jpeg image object. I require the amount of changes (percentage 0-100) between two frames.
The function currently supports a mask, which allows certain areas of the image to be excluded from detection (will still be required).
Aim is to speed up the comparison by at least factor 10.
Also I would like to have the following features added:
1. normalize brightness (changing light conditions should not trigger the detection function as much) - maybe some kind of edge detection would be better than just adding up brightness for each color
2. return image diff / patch file/data - create data that can be applied to an image (object or jpeg data) to add the change between the two images. Also to visualize the change (say black background (unchanged) and the pixels / areas that have changed in a different color.
This may require a PHP extension written in C / C++ - or some external image library. As this detection needs to run constantly (camera image stream), no external (fork / exec) can be used.
#function motion_img_diff($img_old, $img_new_data, $tlx=0, $tly=0, $brx=0, $bry=0)
img_old = php image object (reference)
img_new_data = jpeg data / image as string
tlx=top left, bottom right etc. for the mask. rectangle - the mask will allow the function to ignore specific parts of the image to be excluded 0<=x<16, 0=<y<12
returns a value between 0 and 1000 - 0 = no change, 1000 = full black/white change - adjusted for the mask
Any further questions please let me know.
Forgot to mention it's PHP 5.3.24 - and CentOS 6.4 64 bit.