Kodi Community Forum
Release Security CAM Overlay add-on - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Program Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=151)
+---- Thread: Release Security CAM Overlay add-on (/showthread.php?tid=182540)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20


RE: [WIP] Security CAM Overlay add-on - kitus_san - 2014-01-28

(2014-01-27, 01:16)kitus_san Wrote: Even if the logs are within "code" tags for convenience?? If that's the only way I can get help, I've be sure to post them there
Here you go http://pastebin.com/TTT5NsGD

thanks in advance,


RE: [WIP] Security CAM Overlay add-on - nickr - 2014-01-28

Code:
[http://192.168.1.13/cgi-bin/CGIStream.cgi?cmd=GetMJStream
followed by
Code:
WARNING: JpegIO: Error 55: Not a JPEG file: starts with 0x%02x 0x%02x
suggests you have the wrong url for a jpeg - looks to me like you are trying to fetch a mjpeg video stream.

Did you say it was a foscam? (or was that someone else?)

For a foscam the url I use is http://user:password@IPADDRESS/snapshot.cgi


RE: [WIP] Security CAM Overlay add-on - kitus_san - 2014-01-28

(2014-01-28, 00:07)nickr Wrote:
Code:
[http://192.168.1.13/cgi-bin/CGIStream.cgi?cmd=GetMJStream
followed by
Code:
WARNING: JpegIO: Error 55: Not a JPEG file: starts with 0x%02x 0x%02x
suggests you have the wrong url for a jpeg - looks to me like you are trying to fetch a mjpeg video stream.

Did you say it was a foscam? (or was that someone else?)

For a foscam the url I use is http://user:password@IPADDRESS/snapshot.cgi

Thanks for your response. Yes, I'm trying to access a Foscam 8909w.

If I use your stream url, the UI seems to freeze (I was sure it was totally locked up to be honest) but after a few seconds I also see the same error message pop up

Code:
"script failed! : script.securitycam"

If I now check the log this is the only thing I see

Code:
23:22:03 T:157179904  NOTICE: -->Python Interpreter Initialized<--

thanks


RE: [WIP] Security CAM Overlay add-on - nickr - 2014-01-28

try the url in a browser first.

On mine I used the camera provided web gui and clicked on "snapshot" which opened a new browser tab with the snapshot.cgi url.

Your camera may of course offer a different url pattern, play around in the browser and see if you can find the right url.


RE: [WIP] Security CAM Overlay add-on - shellacbeetle - 2014-01-29

Hi iolaus,

Thanks for your hard work on this addon. when i can get it to work, it's going to be a wonderful addition to our XBMC setup.

I have a Tenvis camera and the your script seems to like the url to be in the form of; http://username:pw@ipaddress:port/snapshot?strm=0

(If I try to use the url without the username/pw and add them into the fields you provide, i get 401 error in the logs)

However the script times out, exhibiting the freezing issue that others have spoken of.
The log states;
Error Type: <class 'socket.timeout'>

The system starts responding again after the timeout period.

Maybe it's an issue with the file format the camera is dishing out? I can use wget and the url above and a jpeg file is saved, so i'm hopeful this isn't the case.

I post in the hope you or someone else has an easy answer. I can pastebin logs if required.

Thanks for your time


[WIP] Security CAM Overlay add-on - kitus_san - 2014-01-29

(2014-01-28, 00:31)nickr Wrote: try the url in a browser first.

On mine I used the camera provided web gui and clicked on "snapshot" which opened a new browser tab with the snapshot.cgi url.

Your camera may of course offer a different url pattern, play around in the browser and see if you can find the right url.
I would swear I did so already, but may need to double check. I'll take a look later on when I'm back home, and report back


RE: [WIP] Security CAM Overlay add-on - iolaus - 2014-02-05

Sorry for going dark for a while, I've been crazy busy lately. Just posted new versions of the add-on for Frodo and Gotham that I believe should take care of the "image not updating" problem some users have been experiencing. Once again, I don't have a Gotham install to test on so please let me know if you run into any issues. Also, for those of you that were having issues with the image updating, please let me know if it is corrected.


RE: [WIP] Security CAM Overlay add-on - warlion - 2014-02-05

Its ok iolaus we understand

Btw the new 0.9 for Gotham works perfect finally its working on Gotham thanks so much


RE: [WIP] Security CAM Overlay add-on - yellow_dre - 2014-02-06

is it possible to add info bar like the original addon from dobiest


RE: [WIP] Security CAM Overlay add-on - iolaus - 2014-02-07

(2014-02-06, 04:18)yellow_dre Wrote: is it possible to add info bar like the original addon from dobiest

I removed this functionality because I wanted the add-on to be more general purpose than just being used for a doorbell. You can recreate the functionality by issuing a couple commands to XBMC, one to display a notification and another to open the security cam overlay.


RE: [WIP] Security CAM Overlay add-on - yellow_dre - 2014-02-08

Can u guide me trough that


RE: [WIP] Security CAM Overlay add-on - warlion - 2014-02-08

(2014-02-08, 03:39)yellow_dre Wrote: Can u guide me trough that


PHP Code:
# Import the modules
import ostimeurllib2xbmcxbmcaddonxbmcguixbmcvfs

# Constants
ACTION_PREVIOUS_MENU 10
ACTION_BACKSPACE 
110
ACTION_NAV_BACK 
92
ADD_ON_ID 
'script.securitycam'

# Set plugin variables
__addon__    xbmcaddon.Addon()
__cwd__      __addon__.getAddonInfo('path').decode("utf-8")
__icon__     xbmc.translatePath(os.path.join(__cwd__'icon.png').encode("utf-8")).decode("utf-8")
__resource__ xbmc.translatePath(os.path.join(__cwd__'resources').encode("utf-8")).decode("utf-8")
__snapshot_dir__ xbmc.translatePath(os.path.join(__resource__'media''snapshots').encode("utf-8")).decode("utf-8")

# Get settings
url       __addon__.getSetting('url')
username  __addon__.getSetting('username')
password  __addon__.getSetting('password')
width     int(float(__addon__.getSetting('width')))
height    int(float(__addon__.getSetting('height')))
interval  int(float(__addon__.getSetting('interval')))
autoClose = (__addon__.getSetting('autoClose') == 'true')
duration  int(float(__addon__.getSetting('duration')) * 1000)

# Methods
def notify():
    
xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%('SecurityCam'time.strftime("%I:%M %p"), duration__icon__))


# Utils

def log(message,loglevel=xbmc.LOGNOTICE):
    
xbmc.log((ADD_ON_ID ": " message).encode('UTF-8','replace'),level=loglevel)

# Classes
class CamPreviewDialog(xbmcgui.WindowDialog):
    
def __init__(self):
        
log('CamPreviewDialog Initialized \n'xbmc.LOGDEBUG)
        
COORD_GRID_WIDTH 1280
        COORD_GRID_HEIGHT 
720
        scaledWidth 
int(float(COORD_GRID_WIDTH) / self.getWidth() * width)
        
scaledHeight int(float(COORD_GRID_HEIGHT) / self.getHeight() * height)
        
self.image xbmcgui.ControlImage(COORD_GRID_WIDTH scaledWidthCOORD_GRID_HEIGHT scaledHeightscaledWidthscaledHeight__icon__)
        
self.addControl(self.image)
        
self.image.setAnimations([('WindowOpen''effect=slide start=%d time=1000 tween=cubic easing=in'%(scaledWidth),), ('WindowClose''effect=slide end=%d time=1000 tween=cubic easing=in'%(scaledWidth),)])

    
def start(selfautoClosedurationintervalurldestination):
        
log('CamPreviewDialog Started \n'xbmc.LOGDEBUG)
        
self.isRunning bool(1)
        
snapshot ''
        
startTime time.time()
        while(
not autoClose or (time.time() - startTime) * 1000 <= duration):
            if 
xbmcvfs.exists(snapshot):
                
os.remove(snapshot)

            
snapshot self.downloadSnapshot(urldestination)

            if 
snapshot != '':
                
self.update(snapshot)

            
xbmc.sleep(interval)
            if 
not self.isRunning:
                break
        
self.close()

    
def downloadSnapshot(selfurldestination):
        
log('Retreiving Image \n'xbmc.LOGDEBUG)
        try:
            
imgData urllib2.urlopen(url).read()
            
filename snapshot xbmc.translatePathos.path.joindestination'snapshot' str(time.time()) + '.jpg' ).encode("utf-8") ).decode("utf-8")
            
output open(filename,'wb')
            
output.write(imgData)
            
output.close()
            return 
filename
        except
:
            return 
''

    
def onAction(selfaction):
        
log('Received Action: ' str(action.getId()) + '\n'xbmc.LOGDEBUG)
        if 
action in (ACTION_PREVIOUS_MENUACTION_BACKSPACEACTION_NAV_BACK):
            
self.isRunning bool(0)
            
self.close()

    
def update(selfimage):
        
log('Updating Image \n'xbmc.LOGDEBUG)
        
self.image.setImage(imagebool(0))
    
# Main execution

log('AutoClose: [' str(autoClose) + ']\n'xbmc.LOGDEBUG)
log('Duration: [' str(duration) + ']\n'xbmc.LOGDEBUG)
log('Interval: [' str(interval) + ']\n'xbmc.LOGDEBUG)
log('Width: [' str(width) + ']\n'xbmc.LOGDEBUG)
log('Height: [' str(height) + ']\n'xbmc.LOGDEBUG)
log('Original URL: [' url ']\n'xbmc.LOGDEBUG)

# Add Basic Authentication Headers
if (username is not None and username != ''):
    
passwordManager urllib2.HTTPPasswordMgrWithDefaultRealm()
    
passwordManager.add_password(Noneurlusernamepassword)
    
authhandler urllib2.HTTPBasicAuthHandler(passwordManager)
    
opener urllib2.build_opener(authhandler)
    
urllib2.install_opener(opener)

# Replace URL agruments
argCount len(sys.argv)
for 
i in xrange(1argCount):
    
search '{%d}'%(1)
    
replace sys.argv[i]
    
url.replace(searchreplace)

log('Final URL: [' url ']\n'xbmc.LOGDEBUG)

xbmcvfs.mkdir(__snapshot_dir__)

notify()

camPreview CamPreviewDialog()
camPreview.show()
camPreview.start(autoClosedurationintervalurl__snapshot_dir__)
del camPreview

dirs
files xbmcvfs.listdir(__snapshot_dir__)
for 
file in files:
    
log('Delete remaining snapshot: [' file ']\n'xbmc.LOGDEBUG)
    
xbmcvfs.delete(os.path.join(__snapshot_dir__file)) 



RE: [WIP] Security CAM Overlay add-on - TheEndless - 2014-02-10

I have a dlink 932L, anybody that can help with the URL configuration. I have tried some, but all seems to hang the add-on and the whole xbmc.


RE: [WIP] Security CAM Overlay add-on - kitus_san - 2014-02-18

Hello,

I finally got this to display my 9821w v2 using this url

http://ip_address/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=user&pwd=password

I may have misunderstood this, but is this add-on supposed to become active when it gets triggered? if so, how?

Sorry that I sound a little loopy right now, but now that I see it manages to display my camera, can I get it to display an overlaid picture permanently, or when motion is detected?

thanks


RE: [WIP] Security CAM Overlay add-on - nickr - 2014-02-19

My understanding is that you need to trigger a JSON call when something in your house detects the security cam picture should be displayed. That could be motion detection, or someone pressing the doorbell, or whatever.

EDIT: there is an example at post 38.