Пример #1
0
    def start(self):       
        #Collects camera configurations and confirm you can connect to at least 1   
        atLeastOneCamera, cameras = common.getSettings()
        common.log_verbose("Number of Cameras to start: " + str(len(cameras)))
        #cameras =
        #       camera_number[0], host[1], port[2], username[3], password[4], preview_enabled[5]
        #       motion_enabled[6], motion_sensitivity[7], motion_trigger_interval[8],
        #       sound_enabled[9], sound_sensitivity[10], sound_trigger_interval[11],
        #       check_interval[12], duration[13], location[14], scaling[15], trigger_interval[16], set_motion_settings[17]    

        if atLeastOneCamera:
            for camera in cameras:
                preview_enabled = camera[5]
                if preview_enabled:
                    atLeastOneCameraPreviewEnabled = True
                    break
                else:
                    camera_number = camera[0]
                    common.log_verbose("Preview disabled for Camera " + camera_number)
                      
        if atLeastOneCameraPreviewEnabled:
            for camera in cameras:
                camera_number = camera[0]
                preview_enabled = camera[5]
                set_motion_settings = camera[17]
                common.log_verbose(camera)
                
                if set_motion_settings:
                    self.configureAlarmSettings(camera)
                else:
                    self.resetCameraAlarmSettings(camera)

                if preview_enabled:
                    t = Thread(target=self.checkAlarm, args=(camera, self.path))
                    t.start()
                    common.log_verbose("Thread Started: Camera " + camera_number)
                
            common.log_normal("Cameras started")

        #Loop required to detect settings changes    
        while not self.monitor.abortRequested():
            self.monitor.waitForAbort(10)  
Пример #2
0
    def __init__(self):
        path = xbmc.translatePath('special://profile/addon_data/%s' % addonid)
        loader = xbmc.translatePath(
            'special://home/addons/%s/resources/media/loader.gif' % addonid)

        if not xbmcvfs.exists(path):
            try:
                xbmcvfs.mkdir(path)
            except:
                pass

        atLeastOneCamera, cameras = common.getSettings()

        #cameras =
        #       camera_number[0], host[1], port[2], username[3], password[4], preview_enable[5]
        #       motion_enabled[6], motion_sensitivity[7], motion_trigger_interval[8],
        #       sound_enabled[9], sound_sensitivity[10], sound_trigger_interval[11],
        #       check_interval[12], duration[13], location[14], scaling[15], trigger_interval[16], set_motion_settings[17]

        if atLeastOneCamera:
            urls = []
            files = []
            for camera_settings in cameras:

                with foscam.Camera(camera_settings) as camera:
                    snapshot_url = camera.snapshot_url

                    urls.append(snapshot_url)
                    files.append(
                        os.path.join(path, camera_settings[0] + '.0.jpg'))

            coords = [  #Bottom Left X, Bottom Left Y, Width, Height
                (12, 12, 622, 342), (646, 12, 622, 342), (12, 366, 622, 342),
                (646, 366, 622, 342)
            ]

            imgs = []
            for c, f in zip(coords, files):
                # aspectRatio: integer - (values 0 = stretch (default), 1 = scale up (crops), 2 = scale down (black bars)
                img = xbmcgui.ControlImage(*c, filename=loader, aspectRatio=0)
                self.addControl(img)
                imgs.append(img)

            # workaround - superimposed image controls to prevent flicker
            imgs2 = []
            for c, f in zip(coords, files):
                img = xbmcgui.ControlImage(*c, filename='', aspectRatio=0)
                self.addControl(img)
                imgs2.append(img)

            cams = [list(l) for l in zip(urls, files, imgs, imgs2)]

            self.show()
            self.isRunning = True

            for i, c in enumerate(cams):
                t = Thread(target=self.getImages, args=(i, c, path))
                t.start()

            while (not xbmc.abortRequested) and (self.isRunning):
                xbmc.sleep(1000)

            for i in xbmcvfs.listdir(path)[1]:
                if i <> "settings.xml":
                    xbmcvfs.delete(os.path.join(path, i))
Пример #3
0
    def __init__(self):
        path = xbmc.translatePath('special://profile/addon_data/%s' %addonid )
        loader = xbmc.translatePath('special://home/addons/%s/resources/media/loader.gif' %addonid )
        

        if not xbmcvfs.exists(path):
            try:
                xbmcvfs.mkdir(path)
            except:
                pass

        atLeastOneCamera, cameras = common.getSettings()

        #cameras =
        #       camera_number[0], host[1], port[2], username[3], password[4], preview_enable[5]
        #       motion_enabled[6], motion_sensitivity[7], motion_trigger_interval[8],
        #       sound_enabled[9], sound_sensitivity[10], sound_trigger_interval[11],
        #       check_interval[12], duration[13], location[14], scaling[15], trigger_interval[16], set_motion_settings[17]    

        if atLeastOneCamera:
            urls = []
            files = []
            for camera_settings in cameras:
                
                with foscam.Camera (camera_settings) as camera:
                    snapshot_url = camera.snapshot_url
                    
                    urls.append(snapshot_url)
                    files.append(os.path.join(path, camera_settings[0] + '.0.jpg'))


            coords = [      #Bottom Left X, Bottom Left Y, Width, Height
                (12, 12, 622, 342),
                (646, 12, 622, 342),
                (12, 366, 622, 342),
                (646, 366, 622, 342)
                ]

            imgs = []
            for c, f in zip(coords, files):
                # aspectRatio: integer - (values 0 = stretch (default), 1 = scale up (crops), 2 = scale down (black bars)
                img = xbmcgui.ControlImage(*c, filename=loader, aspectRatio = 0)
                self.addControl(img)            
                imgs.append(img)


            # workaround - superimposed image controls to prevent flicker
            imgs2 = []
            for c, f in zip(coords, files):
                img = xbmcgui.ControlImage(*c, filename='', aspectRatio = 0)
                self.addControl(img)            
                imgs2.append(img)
            

            cams = [list(l) for l in zip(urls, files, imgs, imgs2)]


            self.show()        
            self.isRunning = True


            for i, c in enumerate(cams):
                t = Thread(target=self.getImages, args=(i, c, path))
                t.start()


            while (not xbmc.abortRequested) and (self.isRunning):       
                xbmc.sleep(1000)   


            for i in xbmcvfs.listdir(path)[1]:
                if i <> "settings.xml":
                    xbmcvfs.delete(os.path.join(path, i))