snowzach / doods

DOODS - Dedicated Open Object Detection Service
MIT License
303 stars 31 forks source link

Add support for fetching image from a URL #29

Closed snowzach closed 3 years ago

snowzach commented 4 years ago

It would be really cool if it also supported grabbing a frame from RTSP (although this would certainly be slower but handy none the less)

EDIT: I created this project to handle this: https://github.com/snowzach/rts2p

MYeager1967 commented 4 years ago

There's other programs out there that will do just that. Frigate will perform object detection on a live stream if that's what you need. I played with it and I'm not really sure it fits my needs.

That said, Snowzach, is there a way to feed it an image from a file? I pull an image every few seconds from motionEye and at the moment I'm having to feed it into HA's camera integration. I'd like to be able to bypass that step and just process the image. I'm doing it from Appdaemon so if there's a direct API I can access that would be a wonderful thing....

Actually, it looks as though it may already be there. I may need some help figuring out how to use it though...

snowzach commented 4 years ago

@MYeager1967 there's a https://github.com/snowzach/pydoods library you can use to call doods from python. It's what home assistant uses. So it should be pretty easy to use that if you just want an easy way to do it from python.

MYeager1967 commented 4 years ago

I'm looking to do it as a straight forward requests.post(). Reason being is that I'm in an environment where it's not exactly easy to import libraries and every update would break it.

KiLLeRRaT commented 4 years ago

This would be good!

Or for me a better alternative would be to have the home assistant doods component have a watch folder, and any file that is dumped in there, is sent to DOODS for processing, and DOODS comes back in its own time etc.. So you can dumpe snapshots in there are 30 FPS if you wanted, and DOODS would process all those frames one at a time, and come back to HA as it processes each frame.

MYeager1967 commented 4 years ago

Are you running Appdaemon? If you are, you can write a python app to do just that. I just finished writing an app that handles the transactions with DOODS completely separate from HA. I don't get the pretty bounding boxes, but I don't want them or I'd go the extra step.

KiLLeRRaT commented 4 years ago

nope, not running AppDaemon. And I like my bounding boxes thank you :P hehe

snowzach commented 4 years ago

I think there is an image component you might be able to do that with

MYeager1967 commented 4 years ago

I was just offering an option. Snowzach, what component might that be? Always nice to know about options even if one chooses not to use them...

snowzach commented 4 years ago

The camera local_file component. Not sure how fast it updates... https://www.home-assistant.io/integrations/local_file/

MYeager1967 commented 4 years ago

Ah yes, I thought you might have been talking about something to do the boxes. The local file camera component is pretty good. I doubt it could keep up with multiple frames per second but I was using it to facilitate the DOODS integration camera requirement before I went full control. Still using it to display last detection picture.

KiLLeRRaT commented 4 years ago

Yeah what we want is async/queueing and it doesn't matter if DOODS keeps up, even if it got around to processing your frames 15 minutes later etc... to me it matters processing the frames I took at 1s intervals, and not to necessarily have it real time.

On Thu, Aug 13, 2020 at 3:37 AM MYeager1967 notifications@github.com wrote:

Ah yes, I thought you might have been talking about something to do the boxes. The local file camera component is pretty good. I doubt it could keep up with multiple frames per second but I was using it to facilitate the DOODS integration camera requirement before I went full control. Still using it to display last detection picture.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/snowzach/doods/issues/29#issuecomment-672949340, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWCPVE4MF6YZ6CU4UGOC7LSAKZMVANCNFSM4PCKIMMA .

--

Albert Gouws

www.gouws.org | sewingmachinecentre.nz

MYeager1967 commented 4 years ago

That's very doable. I can also see a use for that. I'd offer to write it for you, but it would be an Appdaemon app....

KiLLeRRaT commented 4 years ago

Heh if you think more people would find it useful, I'd say go for it. If not, then please don't put in any effort just for me :)

I'd have to get around getting appdaemon set up and such.

How hard is it turning an appdaemon script into a home assistant addon later down the road?

On Thu, Aug 13, 2020 at 1:09 PM MYeager1967 notifications@github.com wrote:

That's very doable. I can also see a use for that. I'd offer to write it for you, but it would be an Appdaemon app....

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/snowzach/doods/issues/29#issuecomment-673188761, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWCPVHGSWMKZHNR4AQZCY3SAM4LHANCNFSM4PCKIMMA .

--

Albert Gouws

www.gouws.org | sewingmachinecentre.nz

MYeager1967 commented 4 years ago

Once you get used to Appdaemon, you'll probably find it easier to do you're scripts and automation there. If you're familiar with python, you know the power you have there. I have all of my automation moved to Appdaemon and all HA really does is handle the device entities. Best thing is, if I have multiple devices, like cameras, that I want to handle exactly alike, I point them all at the same bit of python code. Any changes I make affect them all without me having to go from one automation to the next making changes. Of you go to set up Appdaemon, get on the discord server first. Easier to get guidance that way. I had minor issues setting up v4 when I upgraded from v3. It was all in the config file, but isn't that usually where the issues are....

1ubuntuuser commented 3 years ago

Hope I'm not hijacking here, but is there a way to pass a file path in the REST api? Something like the following would be great.

{
    "detector_name": "default",
    "url": "/var/lib/camera/pic.png",
    "detect": {
        "*": 50
    }
}
snowzach commented 3 years ago

@danielwilson654 are you running doods on the same box as the file? You want to map a volume for doods and have it read from there? If so, I could look at adding support. Someone else asked about it also.

1ubuntuuser commented 3 years ago

Yes same box, that would be awesome!

1ubuntuuser commented 3 years ago

@snowzach I suppose even if you aren't running on the same box, you could pretty easily set up a NFS mount. Support for watching the folder is probably unnecessary, but I'm assuming it would be more efficient than reading the file, converting it to base64 and sending it over http.

snowzach commented 3 years ago

Okay, I added an option for detection called file that will read a local file. It will override the data parameter.

1ubuntuuser commented 3 years ago

Thank you! will give it a test!