330
edits
No edit summary |
|||
(33 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
[[File:blobDetect1.jpg]] | [[File:blobDetect1.jpg]] | ||
'''Code in Processing''' | |||
I am using Blobdetection library written by Mario Klingemann <http://incubator.quasimondo.com> in Processing Opencv to help me with the code part. So that I can get the data of blobs, and therefore to count the amounts of blobs to get the amounts of visitors in the platform. | |||
'''And here is the github link for my full code:''' <https://github.com/ConnorFk/DBL_VisitorsCount> | |||
<source lang="Java" line start= "17"> | |||
printArray(Capture.list());//to get the webcam source list | |||
//cam = new Capture(this, 640, 480); //default webcam in your laptop | |||
cam = new Capture(this, 640, 480, Capture.list()[2]);//Logitech C270 Webcam | |||
// Comment the following line if you use Processing 1.5 | |||
cam.start(); | |||
</source> | |||
[[File:codeProcessing1.jpg]] | |||
<source lang="Java" line start= "32"> | |||
// ================================================== | |||
// captureEvent() | |||
// ================================================== | |||
void captureEvent(Capture cam) | |||
{ | |||
cam.read(); // to start the webcam | |||
newFrame = true; // keep grabbing the new frames | |||
} | |||
void draw() | |||
{ | |||
if (newFrame) | |||
{ | |||
newFrame=false; | |||
image(cam,0,0,width,height); | |||
img.copy(cam, 0, 0, cam.width, cam.height, | |||
0, 0, img.width, img.height); | |||
fastblur(img, 2); | |||
theBlobDetection.computeBlobs(img.pixels); | |||
drawBlobsAndEdges(true,true); | |||
} | |||
count = theBlobDetection.getBlobNb(); // get the numbers of blobs captured | |||
println(count); // print out the numbers in Processing console | |||
} | |||
</source> | |||
[[File:codeProcessing2.jpg]] | |||
==Webcam Setup of the DBL== | ==Webcam Setup of the DBL== | ||
'''Hanging of Webcam''' | |||
Hanging webcam on the roof in DBL is not so difficult, you can use the staircase and plastic cable zip to install it on the silver beam, but PLEASE do remember to put the paperboard to under the staircase to make sure not destroy the platform. | |||
[[File:webcamSet-01.jpg]] | |||
[[File:webcamSet-02.jpg]] | |||
[[File:webcamSet2.jpg]] | |||
'''Hardware: Webcam''' | |||
Due to the height of DBL lab is only around 2.5 meters, so when a normal webcam is set on the roof, the capture area is quite limited. I tried with several cheap webcams I can get: | |||
1: '''fitTek'''[https://www.amazon.de/fitTek-Webcam-Kamera-Desktop-Winkeleinstellbar/dp/B00LLWASXK/ref=sr_1_10?s=computers&ie=UTF8&qid=1469870860&sr=1-10&keywords=webcam] which is fine and cheap to test with blob detection, but it is not so stable and accurate cause its low resolution. | |||
2: '''Logitech C270'''[https://www.amazon.de/Logitech-960-001063-001063%C2%A0960%C2%A0HD-Webcam-C270%C2%A0Black/dp/B01BGBJ8Y0/ref=sr_1_3?s=computers&ie=UTF8&qid=1469870860&sr=1-3&keywords=webcam] which is not so expensive with high resolution and wide angle display. | |||
'''Software: Logitech Camera Settings''' | |||
Since I decided to use Logitech C270, I found there will have a problem to drive it in Mac OS. It is totally fine if you are using PC, you can download the driver for your PC here:[http://support.logitech.com/en_ca/product/hd-webcam-c270] | |||
For who are using Mac OS, you can go to app store and download the app called: Logitech Camera Settings. It is quite useful and you can use it to set Logitech webcam as your webcam input source in your mac laptop, more importantly, you can use it to change the settings of your external Logitech webcam, such as: Brightness; Contrast; Color Intensity; White Balance, which will be very useful to have a better settings for blob detection. | |||
'''Blob Detection with default settings''' | |||
[[File:webcamTest3.jpg]] | |||
'''Blob Detection with customized settings''' | |||
[[File:webcamTest4.png]] | |||
You can change the webcam settings to better serve for your blob detection according to the light environment, hence, you will have more accurate result about the amount of visitors in the capture area. | |||
==Limitation / Attention== | |||
Blob detection is still not the most accurate one to calculate the amount of visitors, but it works somehow in this case, you need to adjust the webcam settings and the light environment in the platform. For the light environment, more bright the background is, there will have stronger pixel difference to be better for the blob detection. And please pay attention to the shadows caused by light, the shadows will also be captured by the webcam, if the shadows are not well controlled, they will interfere the accuracy to calculate. | |||
I was once planning to also set up a spotlight in the platform to test my project, then I found the shadows are big factors in calculating the blobs. | |||
[[File:limit-08.jpg]] | |||
[[File:limit-07.jpg]] | |||
[[File:limit-09.jpg]] |
edits