Domanda

I am doing a web application where i am pulling in an image from an IP camera, and I need to be able to see if there is a car in the parking spot. I wanted to do this using some sort of shape detection but all I can seem to find is face detection port from c++ and basic shapes such as squares. Can someone point me in the right direction so I can make my own shape detection?snapshot of cam Right now I am drawing the blue box and getting the images data for the x,y,h,w and seeing if I can get any other colors besides the 0xFFFFFF of the parking lot but it doesnt work at night at it will be skewed for humans walking.

Any help would be appreciated..

function drawgrid(){
  context.drawImage(img, 0, 0);
  localStorage.setItem( "savedImageData", canvas.toDataURL("image/png") );
  context.beginPath();
  context.rect(308, 240, 250, 100);
  context.lineWidth = 2;
  context.strokeStyle = 'blue';
  context.stroke();
  var dataURL = canvas.toDataURL();
}

this is grabbing image data saving it to local storage where I then loop through every pixel, however I don't think this is the correct way of going about it.

È stato utile?

Soluzione

The question is perhaps a bit broad for SO but you can use something like the following approach to get closer:

  • For each sampled image, convert it to grey-scale and subtract the previous image (or sample a main frame every now and then and use that as a subtractor for the new frame).
  • Apply a threshold filter - all values below convert to black, all above to white
  • Apply erosion filter to deal with pixels as a result of noise in the image
  • Apply statistical measures to determine if number of changed pixels in a region should trigger an "alarm".

It sounds perhaps simple enough but you are in for a variety of challenges such as light conditions and noise, small movements versus large movements. It's (almost) all about finding and tweaking the values, sample rates, threshold values until you have something that matches your situation. The values will vary for day and night light conditions, for example in the night or when poor light (cloudy, heavy dark weather) you will have to deal with a lot of noise in the image. For cloudy and windy days where light changes a lot you will have to deal with thresholds and sample rates, if your camera is set to automatically adjust itself you will have various luminance values depending on white balance (even when converted to grey-scale), f-stop, shutter-time and so on.

They will all affect the result but it's how much will allow this to affect which determines the results in the end and where the statistical part comes in.

There are several other ways but it's a very broad topic. In any case, I hope this can give you some points in the hopefully right direction.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top