Anil Kumble Circle – Time Lapse video

BTIS.IN provides images from traffic cameras across Bangalore. I wrote a simple script to capture and store images from camera no 3 (Anil Kumble Circle). Code is very simple and is listed below.

$img[]='http://www.btis.in/cameras/images/3.jpg';
foreach($img as $i){
    save_image($i);
    echo 'Image Downloaded OK';
}
function save_image($img,$fullpath='basename'){
    if($fullpath=='basename'){
        $fullpath = basename($img);
    }
    $dateTime = new DateTime("now", new DateTimeZone('Asia/Calcutta'));
    $ts = $dateTime->format("Y_m_d_H_i_s");
    $ch = curl_init ($img);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
    $rawdata=curl_exec($ch);
    curl_close ($ch);
    $fp = fopen($ts.'.jpg','w');
    fwrite($fp, $rawdata);
    fclose($fp);
}

The camera AK circle is usually up from morning 6 to evening 7. I have about 1.3k valid pictures from last four months. I stitched them together to form a time lapse video.

ls -1tr > files.txt
mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4 -o test.avi -mf type=jpeg:fps=15 mf://@files.txt

I wish there was a public web cam looking at any metro construction.

6 Responses

  1. It would have been cooler if only one cam input was captured and shown.

  2. It would have been cooler if only cam did not change position

  3. Veera says:

    //The camera AK circle is usually up from morning 6 to evening 7.//

    Does that mean the camera is switched off in the later hours!? But I don’t understand the reason, though. Is Govt so sure that crimes won’t happen after 7!? :)

    Or the purpose of the camera is just to measure traffic in the daytime?

    • Thejesh GN says:

      I really don’t know. I have the script scheduled to capture one picture every hour. In last four months I have got pics only for that time period. Hence its kind of an assumption!

  4. Mainak says:

    Very Cool Idea!!