Page 1 of 5

SecuritySpy Image Downloading and Stitching

PostPosted: Sat Feb 24, 2018 1:24 pm
by vtmikel
I've created a utility plugin for SecuritySpy. I designed the plugin to ease the combined use of SecuritySpy with the Pushover plugin. SecuritySpy, even when running on the same Mac as Indigo, does not easily make available a jpg of each camera for Indigo to reference. The webcam feature only allows for FTP uploads which is not convenient.

With this plugin, you can:
  • Download individual camera snapshots from SecuritySpy, and save them to your Mac to a location you choose, driven by a variable.
  • Download multiple camera snapshots from SecuritySpy, and stitch them together vertically into a single image to a location you choose, driven by a variable

Once you do the above actions, it's easy to use the same variable to use an image in a Pushover notification. For example, if you saw motion in your camera, and you wanted to send yourself a notification with the image from that camera, this is now easy to accomplish.

I have not posted to the plugin store, yet. Available for testing here: https://github.com/mlamoure/indigo-secu ... downloader

Mike

Re: SecuritySpy Image Downloading and Stitching

PostPosted: Sat Feb 24, 2018 2:32 pm
by FlyingDiver
You're going to need to patch your version of ghpu.py to the curl version, as the version you're using is broken now.

Re: SecuritySpy Image Downloading and Stitching

PostPosted: Sat Feb 24, 2018 5:45 pm
by vtmikel
Will do thanks


Sent from my iPhone using Tapatalk Pro

Re: SecuritySpy Image Downloading and Stitching

PostPosted: Sun Feb 25, 2018 6:21 am
by vtmikel
I wasn’t aware of the problems with the ghpu because I’m running HS. I’ll do the same as you and remove while we wait for a plug-in store update mechanism.


Sent from my iPad using Tapatalk Pro

Re: SecuritySpy Image Downloading and Stitching

PostPosted: Sun Feb 25, 2018 6:42 am
by FlyingDiver
vtmikel wrote:
I wasn’t aware of the problems with the ghpu because I’m running HS. I’ll do the same as you and remove while we wait for a plug-in store update mechanism.


I ended up patching ghpu.py with this code. Just substitute this for the original _GET function:

Code: Select all
    def _GET(self, requestPath):
        self.logger.debug('GET %s' % requestPath)
        headers = {
            'User-Agent': 'Indigo-Plugin-Updater',
            'Accept': 'application/vnd.github.v3+json'
        }
        data = None
        f = subprocess.Popen(["/usr/bin/curl",  'https://api.github.com'+ requestPath], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
        out, err = f.communicate()
        self.logger.debug(u'HTTP Err result: ' + unicode(err) )
        self.logger.debug(u'ReturnCode:{0}'.format(unicode(f.returncode)))
     
        if (int(f.returncode) == 0):
            data = json.loads(out)
            self.logger.debug(u'Json results:' + unicode(data))
        elif (400 <= f.status < 500):
            error = json.loads(out)
            self.logger.error('%s' % error['message'])
        else:
            self.logger.error('Error: %s' % unicode(err))
       
        return data

Re: SecuritySpy Image Downloading and Stitching

PostPosted: Sun Feb 25, 2018 1:08 pm
by ZachBenz
vtmikel wrote:
With this plugin, you can:
  • Download individual camera snapshots from SecuritySpy, and save them to your Mac to a location you choose, driven by a variable.
  • Download multiple camera snapshots from SecuritySpy, and stitch them together vertically into a single image to a location you choose, driven by a variable


Awesome! I've been wanting something just like this. Don't suppose you'd be interested in adding a third option to stitch them together into an animated GIF (and/or movie)? :-)

Re: SecuritySpy Image Downloading and Stitching

PostPosted: Tue Feb 27, 2018 3:07 pm
by vtmikel
ZachBenz wrote:
vtmikel wrote:
With this plugin, you can:
  • Download individual camera snapshots from SecuritySpy, and save them to your Mac to a location you choose, driven by a variable.
  • Download multiple camera snapshots from SecuritySpy, and stitch them together vertically into a single image to a location you choose, driven by a variable


Awesome! I've been wanting something just like this. Don't suppose you'd be interested in adding a third option to stitch them together into an animated GIF (and/or movie)? :-)


You may be overestimating my python skills! GIF's dont seem to be supported by pushover, which was my main reason for building the plugin. I'm not opposed if I can find a simple example to use.

Re: SecuritySpy Image Downloading and Stitching

PostPosted: Wed May 09, 2018 12:14 am
by agame
very handy, thankyou!
Ive noticed the stitched image fails altogether if one of the Security Spy cams is unavailable.
I have a couple of flakey cams that go up and down for their own reasons.
might would be more elegant if the remaining image(s) still got stitched.

Re: SecuritySpy Image Downloading and Stitching

PostPosted: Wed May 09, 2018 3:47 pm
by vtmikel
agame wrote:
very handy, thankyou!
Ive noticed the stitched image fails altogether if one of the Security Spy cams is unavailable.
I have a couple of flakey cams that go up and down for their own reasons.
might would be more elegant if the remaining image(s) still got stitched.


Thanks for the report.

Assuming I can reproduce it, I’ll get it fixed. Can you post the error you get?


Sent from my iPhone using Tapatalk Pro

Re: SecuritySpy Image Downloading and Stitching

PostPosted: Fri May 11, 2018 8:37 am
by vtmikel
agame wrote:
very handy, thankyou!
Ive noticed the stitched image fails altogether if one of the Security Spy cams is unavailable.
I have a couple of flakey cams that go up and down for their own reasons.
might would be more elegant if the remaining image(s) still got stitched.



Give 1.0.2 a try and see if that resolves the problem you were having. I've made it so that if any camera isn't available, it will move on with the ones that are available.

Re: SecuritySpy Image Downloading and Stitching

PostPosted: Sat May 12, 2018 4:41 pm
by agame
apologies was offline ... will do today/!

Re: SecuritySpy Image Downloading and Stitching

PostPosted: Sun May 13, 2018 7:24 pm
by agame
I have tested it, and it works!
I attempted to stitch 4 cams, of which only 1 is operational - as hoped I get a single image saved in the specified directory.
I assume as intended there is an error message reported as follows (though not sure why its reporting just temp2 missing - presumably all but temp 1 would have been?):

Action Group capture and stitch gate cams
Image Downloader and SecuritySpy Helper getting image: http://xxxx/++image?cameraNum=2 and saving it to: /Users/yyyy/SecuritySpy/temp1.jpg
Image Downloader and SecuritySpy Helper Debug completed
Image Downloader and SecuritySpy Helper getting image: http://xxxx/++image?cameraNum=4 and saving it to: /Users/yyyy/SecuritySpy/temp2.jpg
Image Downloader and SecuritySpy Helper Error error getting image. Status code: 404
Image Downloader and SecuritySpy Helper Debug error obtaining image 2, skipping
Image Downloader and SecuritySpy Helper getting image: http://xxxx/++image?cameraNum=1 and saving it to: /Users/yyyy/SecuritySpy/temp3.jpg
Image Downloader and SecuritySpy Helper Error error getting image. Status code: 404
Image Downloader and SecuritySpy Helper Debug error obtaining image 3, skipping
Image Downloader and SecuritySpy Helper getting image: http://xxxx/++image?cameraNum=3 and saving it to: /Users/yyyy/SecuritySpy/temp4.jpg
Image Downloader and SecuritySpy Helper Error error getting image. Status code: 404
Image Downloader and SecuritySpy Helper Debug error obtaining image 4, skipping
Image Downloader and SecuritySpy Helper Error Error in plugin execution ExecuteAction:

Traceback (most recent call last):
File "plugin.py", line 178, in stitchImageAction
OSError: (2, 'No such file or directory', '/Users/yyyy/SecuritySpy/temp2.jpg')

Re: SecuritySpy Image Downloading and Stitching

PostPosted: Sun May 13, 2018 7:51 pm
by vtmikel
Looks like I have to fix the cleanup code. It's failing trying to delete the temporary files that are created for each camera, since some of the cameras failed.

I need to revisit the event log output for this plugin, it's quite ugly. I'll put that on my list too.

Re: SecuritySpy Image Downloading and Stitching

PostPosted: Mon May 14, 2018 6:15 am
by agame
all nice to have...but lovely that it works regardless!

Re: SecuritySpy Image Downloading and Stitching

PostPosted: Thu May 17, 2018 1:38 pm
by vtmikel
Version 1.1 makes the fixes to the temporary file cleanup after stitching if the cameras weren't available.

Also, if you are using Cynical SecuritySpy plugin with your cameras configured, the action dialogs will now automatically load the camera numbers and names.