2015-02-18, 12:10
This is a thread to discuss the Multi Cam addon originally posted at http://forum.kodi.tv/showthread.php?tid=...pid1854332
(2015-02-18, 14:14)Shigoru Wrote: Hi Leopold
as wrot on github. Your addon has an counter for the pictures you are storing in the userdata addon folder. It would be good to delete the pictures from time to time. If you have running the the addon some time the this uses a lot of space there.
Bye Shigoru
for f in glob.glob(os.path.join(data_path, "*.jpg")):
os.remove(f)
(2015-03-09, 21:18)Shigoru Wrote: Hi Extraze
here is what you are searching for - 6 cam Version
https://github.com/Shigoru/script.securitycams
The beers should go to 4lb3rtO who did all the work on the script.
Just change the coordinates in the default.py to
coords = (
(12, 360, 205, 160),
(222, 360, 205, 160),
(432, 360, 205, 160),
(642, 360, 205, 160),
(852, 360, 205, 160),
(1062, 360, 205, 160),
)
if you would like to get it in fullscreen mode.
The script is flickering much at the moment but the refresh rate is very high now. I would decrease the sleep time in the script from 50 to 800ms which works much better for me.
Regards Shigoru
(2015-03-09, 20:46)Extraze Wrote: on a side note, I find that there is a 5 to 10 second lag between the actual image on the screen and what is happening in front of the camera. Is it really optimal to capture the image and then save to a file and then read it ? is it possible to simply throw whatever is "seen" via the URL directly on screen ? bypassing the read/write cycle on the sdcard completely ? can the image be saved in memory or something ? (this might sound stupid so please correct me) !Unfortunately that's not possible currently as the image must be a file on disk. If you are running in Linux you could create a ramdisk and set the script to use that.
(2015-03-10, 16:23)Extraze Wrote: if a camera is lagging for whatever reason, the entire program waits for that camera's feed, and after X amount of seconds (maybe a minute or two) the program freezes (this probably explains Shigoru's flickering at low refresh rates too) ... so if the camera doesn't respond, all the others don't get refreshed either, and after some time the program just stops its operation and everything stays static until you close the program or reboot the pi.Yes the version I initially provided was a very "quick and dirty" proof of concept. Ideally each image should be updated in a separate thread.
is there a way for every camera to be updated independently instead one following the other ?, this would prevent 1 single point of failure from affecting everything else.
(2015-03-09, 21:18)Shigoru Wrote: Hi Extraze
here is what you are searching for - 6 cam Version
https://github.com/Shigoru/script.securitycams
The beers should go to 4lb3rtO who did all the work on the script.
Just change the coordinates in the default.py to
coords = (
(12, 360, 205, 160),
(222, 360, 205, 160),
(432, 360, 205, 160),
(642, 360, 205, 160),
(852, 360, 205, 160),
(1062, 360, 205, 160),
)
if you would like to get it in fullscreen mode.
The script is flickering much at the moment but the refresh rate is very high now. I would decrease the sleep time in the script from 50 to 800ms which works much better for me.
Regards Shigoru
import xbmc
import xbmcgui
import xbmcvfs
import xbmcaddon
import os.path
from urllib import urlretrieve
from PIL import Image
from threading import Thread
addon = xbmcaddon.Addon()
addonid = addon.getAddonInfo('id')
addonname = addon.getAddonInfo('name')
black = os.path.join(addon.getAddonInfo('path'), 'resources', 'media', 'black.png')
ACTION_PREVIOUS_MENU = 10
ACTION_STOP = 13
ACTION_NAV_BACK = 92
ACTION_BACKSPACE = 110
class CamWindow(xbmcgui.WindowDialog):
def __init__(self):
self.addControl(xbmcgui.ControlImage(0, 0, 1280, 720, black))
path = xbmc.translatePath('special://profile/addon_data/%s' %addonid )
loader = xbmc.translatePath('special://home/addons/%s/resources/loader.gif' %addonid )
if not xbmcvfs.exists(path):
xbmcvfs.mkdir(path)
urls = [
addon.getSetting('URL1'),
addon.getSetting('URL2'),
addon.getSetting('URL3'),
addon.getSetting('URL4'),
addon.getSetting('URL5'),
addon.getSetting('URL6')
]
files = [
os.path.join(path, '1.0.jpg'),
os.path.join(path, '2.0.jpg'),
os.path.join(path, '3.0.jpg'),
os.path.join(path, '4.0.jpg'),
os.path.join(path, '5.0.jpg'),
os.path.join(path, '6.0.jpg')
]
coords = (
(0, 0, 425, 359),
(428, 0, 424, 359),
(855, 0, 425, 359),
(0, 362, 425, 359),
(428, 362, 424, 359),
(855, 362, 425, 359),
)
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)
cams = [list(l) for l in zip(urls, files, imgs)]
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(2000)
for i in xbmcvfs.listdir(path)[1]:
if i <> "settings.xml":
xbmcvfs.delete(os.path.join(path, i))
def getImages(self, i, c, path):
x=0
while (not xbmc.abortRequested) and (self.isRunning):
try:
x+=1
c[1] = os.path.join(path, '%d.%d.jpg') %(i, x)
urlretrieve(c[0], c[1])
#self.resizeImg(c[1])
c[2].setImage(c[1], useCache=False)
xbmcvfs.delete(os.path.join(path, '%d.%d.jpg') %(i, x-1))
xbmc.sleep(2200)
except Exception, e:
xbmc.log(str(e))
#error = xbmc.translatePath('special://home/addons/%s/resources/error.png' %addonid )
#c[2].setImage(error, useCache=False)
def onAction(self, action):
if action in (ACTION_PREVIOUS_MENU, ACTION_STOP, ACTION_NAV_BACK, ACTION_BACKSPACE):
self.isRunning = False
self.close()
#def resizeImg(self, IMAGEFILE):
# if xbmcvfs.exists(IMAGEFILE):
# img = Image.open(IMAGEFILE)
# img = img.resize((1280, 720))
# img.save(IMAGEFILE)
CW = CamWindow()
del CW
black = os.path.join(__addon__.getAddonInfo('path'), 'resources', 'media', 'black.png')
self.addControl(xbmcgui.ControlImage(0, 0, 1280, 720, black))
coords = (
(0, 0, 425, 359),
(428, 0, 424, 359),
(855, 0, 425, 359),
(0, 362, 425, 359),
(428, 362, 424, 359),
(855, 362, 425, 359),
)