IMAQ`StartCamera[];(*AcessingCamera*)background=ColorConvert[CurrentImage[],"GrayScale"];(*Takingpictureandusingittocomparewithfutureimages.*)(*Alltheotherframeswillbecomparedtothisone.*)val:=CurrentImage[];(*Toacessthecurrentimagewhenvaliscalled.*)Dynamic[ListLinePlot[data,Mesh->All,MeshStyle->Red,AxesLabel->{"time in seconds","Intensity"}]](*Dynamicallyplotintenstityvstime*)Dynamic[diffimag](*ShowingtheDifferencebetweenImages*)data={};(*Datalist*)t=0(*parameter*)While[t<=3000,gray=ColorConvert[val,"Grayscale"];diffimag=ImageDifference[gray,background];(*Findingdifferencebetweencurrentimageandinitialimageconvertedtograyscale.*)intensevals=Flatten@ImageData[diffimag];(*Flatteningtheimagedataarray*)v=Total[intensevals];(*Totalofallarraystofindintensity*)data=AppendTo[data,{t,v}];(*Appendingintensityvaluestodata*)If[v>3000,EmitSound[Sound[SoundNote[]]];;];(*Emmitingsoundifintensityismorethanthreshold*)(*Thresholdcanbechangedbasedonsurrounding*)t++;(*IncreasingParameter.*)]IMAQ`StopCamera[];