GithubHelp home page GithubHelp logo

Comments (6)

psyciknz avatar psyciknz commented on August 17, 2024 1

yep pretty much

from cameraevents.

psyciknz avatar psyciknz commented on August 17, 2024

Hi.

No there's a call in there (a curl command) to an API on the camera/nvr that is a stream of events. So when an event is triggered it writes to that stream (the code is in the OnReceive method at this point), it then looks for some info in the received event and then calls for a snapshot image and post out an mqtt message.

from cameraevents.

ChillXXL avatar ChillXXL commented on August 17, 2024

OnReceive

So This line?

CurlObj.setopt(pycurl.WRITEFUNCTION, device.OnReceive)

I am new to cURL but familiar with HTTP requests. Can I see a cURL as a sort of 'hotline' (read: direct connection) and refreshes automatically the content on the line as frequent as possible and doesn't close the connection like a HTTP request does?

Sort of like a website and F5 refresh is pushed as much as possible so the content gets updated every time?

from cameraevents.

psyciknz avatar psyciknz commented on August 17, 2024

thats setting an option for pycurl -to use the onreceive method for any data written by pycurl.

Pycurl, is a python implemention of the cUrl binary. So instead of a single call, which exits, the dahua api, keeps the stream open, and when events occur they write to that open curl stream.
Eg:

--myboundary
Content-Type: text/plain
Content-Length:37
Code=VideoMotion;action=Start;index=5
--myboundary
Content-Type: text/plain
Content-Length:37
Code=VideoMotion;action=Start;index=5

Is what is received for a videomotion event. So when I see that, I can see the camera (index 5) and that it's a start. A stop event is also triggered which is the end of the event.

Most of the pycurl stuff came from another source. THen I added the MQTT and snapshot extraction.

from cameraevents.

ChillXXL avatar ChillXXL commented on August 17, 2024

Thanks for the info. So there is only one initial connection (continuously) made to the Dahua device from your python script and the Dahua NVR or CAM PUSHes data, like your example above, towards the stream when a event occurs. Then in your code this is followed by a function like IF data is received AND you find string-data like 'VideoMotion' and 'action=Start' THEN to do some MQTT handling ELSE do x. Like this?

from cameraevents.

ChillXXL avatar ChillXXL commented on August 17, 2024

Thanks! cURL and open stream are the keywords :-) I do understand now. Thumps up for the app. I shall close the issue.

from cameraevents.

Related Issues (20)

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.