[英]Shape detection javascript canvas
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. 我正在做一个网络应用程序,我从IP摄像机中提取图像,我需要能够看到停车位是否有车。 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. 我想使用某种形状检测来做到这一点,但我似乎能找到的是来自c ++的面部检测端口和基本形状,例如正方形。 Can someone point me in the right direction so I can make my own shape detection? 有人能指出我正确的方向,所以我可以自己进行形状检测吗? 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. 现在我正在绘制蓝色框并获取x,y,h,w的图像数据,看看除了停车场的0xFFFFFF之外我是否可以获得任何其他颜色但是它在夜间不起作用将会产生偏差人类走路。
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. 这是抓取图像数据将其保存到本地存储,然后我遍历每个像素,但我不认为这是正确的方法。
The question is perhaps a bit broad for SO but you can use something like the following approach to get closer: 对于SO来说,问题可能有点宽泛,但您可以使用类似以下方法的方法来更接近:
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. 对于光线变化很大的阴天和大风日,您将不得不处理阈值和采样率,如果您的相机设置为自动调整,您将根据白平衡获得各种亮度值(即使转换为灰度), f-stop,快门时间等。
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. 无论如何,我希望这可以给你一些有希望的方向点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.