Git Product home page Git Product logo

Comments (6)

turbo avatar turbo commented on June 8, 2024

The failing command is ofc plt.imshow(frame)

from pedestrian-cam.

brian-yu avatar brian-yu commented on June 8, 2024

Hi @turbo , I am unable to recreate this bug-- I wrote this using Python 3.6 and OpenCV 3.3.0, can you check to make sure you have the right versions?

from pedestrian-cam.

turbo avatar turbo commented on June 8, 2024

This seems to be a very widely known issue: ContinuumIO/anaconda-issues#121

None of the workarounds work for me though.

from pedestrian-cam.

brian-yu avatar brian-yu commented on June 8, 2024

Hmm. I installed OpenCV 3.3 using Conda Forge. I think this may have helped me avoid those issues.

from pedestrian-cam.

turbo avatar turbo commented on June 8, 2024

Even with Conda Forge OpenCV, the stream loading fails:

OpenCV: Couldn't read video stream from file "http://192.65.213.243/mjpg/video.mjpg"

So I used this minimal mjpeg frame proxy (PHP):

<?php

header("Access-Control-Allow-Origin: *");

function mjpeg_grab_frame($url) {
    $f = fopen($url, 'r');
    if($f) {
        $r = null;
        while(substr_count($r, "\xFF\xD8") != 2) $r .= fread($f, 512);
        $start = strpos($r, "\xFF\xD8");
        $end = strpos($r, "\xFF\xD9", $start)+2;
        $frame = substr($r, $start, $end-$start);
        fclose($f);
        return $frame;
    }
}
header("Content-type: image/jpeg");
die(mjpeg_grab_frame($_REQUEST['src']));

Started with php -S localhost:8000. Then this will work:

URL = 'http://localhost:8000/?src=http://192.65.213.243/mjpg/video.mjpg'

# Test capturing a frame from mJPG
cap = cv2.VideoCapture(URL)

ret, frame = cap.read()

from pedestrian-cam.

brian-yu avatar brian-yu commented on June 8, 2024

Wow, clever solution! I'll keep an eye out for this problem in the future, should I encounter it.

from pedestrian-cam.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.