eduardolundgren / tracking.js

A modern approach for Computer Vision on the web
http://trackingjs.com
Other
9.43k stars 1.44k forks source link

LIVE image detection with fullHD Quality #281

Open myinzack opened 6 years ago

myinzack commented 6 years ago

Hi All,

Currently we are able to install tracking.js and run it from laptop webcam. moving ahead, we want to detect faces from longer distance (maybe 20 feet) assuming we have atleast 8 MP camera. The face detection image should have fullHD quality (1920 * 1080p)

In the existing scenario we are not able to exceed face detection beyond 3-4 feet and image detected (with 8 MP camera) is at very low quality. please suggest

Thanks vijay

murat-aka commented 6 years ago

face is getting smaller at distance. put image into a big canvas, that might help

thexeos commented 6 years ago

If you are using tracking.track('#video', tracker, { camera: true }), then you can try changing the tracking.initUserMedia_ in build/tracking.min.js. Where it says video: true, you can put something like this in:

video: {
    width: {
        ideal: 1920
    },
    height: {
        ideal: 1080
    }
},

Which will result in video stream getting captures at 1080p, however mind the extra load. Unless you have a powerful CPU, the detection will take longer, and you will probably drop to 1-2 FPS for results. In that case, you will need to write a custom function, that takes the video stream and downscales it (for example by drawing to canvas) by a factor of 2 or 4, until it starts detecting faces.

Then you can decide what to do next based on your use case. If you need an accurate face position, then you can crop the FullHD image around the detected face and start passing that to the tracker. If the face starts approaching the crop border, then move the crop area to that side. In the mean time, you can continue sending low quality versions for detection, which will take a fraction of a second. This way, you can easily track multiple faces on a FullHD stream, without hitting the CPU limits.