eduardolundgren / tracking.js

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

face detection using IP camera #294

Open vijaysagi1 opened 6 years ago

vijaysagi1 commented 6 years ago

Hi all,

Please suggest how can i access IP camera and undergo face detection

Thanks vijay

vijaysagi1 commented 6 years ago

i think i need to configure rtsp://xx.xx.xx.xx:554/Streaming/Channels/1 to read the video feed. Currently am stuck how to do face detection on RTSP

alexandermaisey commented 6 years ago

I don't believe html5 video tags can accept RTSP. You might consider using video.js with the HLS add-on to make it work. Once you have your RTSP feed rendering correctly inside the video tag, tracking.js should work normally.

vijaysagi1 commented 6 years ago

Thanks Alex,

Pls suggest using tracking.js can i read http stream remotely from IP camera ?

alexandermaisey commented 6 years ago

Not directly. You will need to figure out how to make the video output of the IP camera stream compatible with an HTML5 video tag, i.e. HLS or MPEG-DASH. I do not know how to accomplish that, but video.js with the HLS add-on (links in my prior response) may be your answer. Once that is setup, you can use tracking.js as it is documented.

wilwad commented 6 years ago

Connecting IP camera to trackingJS

I have connected IP camera to tracking.js by using jsmpeg (https://github.com/phoboslab/jsmpeg). I am using ubuntu Linux. My face tracking is not working but at least you can see how to use IP camera.

Use ffmpeg to stream IP camera to jsmpeg: ffmpeg -i rtsp://192.168.8.105:554/onvif1 -b:v 50k -r 30 http://127.0.0.1:8096/jsmpeg_secret/1280/720

In my test html page: consume the incoming video // rough copy, from my code capture

< canvas id="videoFeed1" width="640" height="480" >< / canvas >

window.onload = function() {  var client1 = new WebSocket( 'ws://192.168.8.101:8097/' );  var feed1 = document.getElementById('videoFeed1');  var player1 = new jsmpeg(client1, {canvas:feed1}); var tracker = new tracking.ObjectTracker('face');

tracker.setInitialScale(4); tracker.setStepSize(2); tracker.setEdgesDensity(0.1); tracking.track(player1.canvas, tracker);

... rest of the tracking code etc };

alexandermaisey commented 6 years ago

To get your face tracking working, you probably don't want everything in window.onload, particularly the tracking.track(...). Try moving that into a callback from the video element (something like, feed1.onloadedmetadata = (e) => { feed1.play(); tracking.track(...); }; )

wilwad commented 6 years ago

Very true. Will try that thank you very much.