Commit 5126f1f2 authored by klorydryk's avatar klorydryk
Browse files

Add Windows positions file read and applied at startup

parent 1afa3723
......@@ -12,7 +12,7 @@ from colour import Color
from threading import Thread
import time
import random
# import tkinter as tk
import json # To write and read windows positions
import randomnames
......@@ -77,7 +77,7 @@ def list_available_cameras():
class facetracker:
#We are not doing really face recognition
#We are not really doing face recognition
# def doRecognizePerson(self, faceNames, fid):
# time.sleep(2)
# faceNames[ fid ] = randomnames.rand_name_statistic(charset) #"Person " + str(fid)
......@@ -575,6 +575,21 @@ if __name__ == '__main__':
facetrackerList.append(facetracker(camera_id, videoName))
data={}
try:
with open('windows_pos.json') as f:
data = json.load(f)
except EnvironmentError: # parent of IOError, OSError *and* WindowsError where available
print ('Windows position file not found: random position')
else:
print(data)
# To move windows to the previous positions
i = 0
for camera in facetrackerList:
cv2.namedWindow(camera.videoName, cv2.WINDOW_NORMAL)
cv2.resizeWindow(camera.videoName, int(data["WindowsList"][i]["width"]), int(data["WindowsList"][i]["height"]))
cv2.moveWindow(camera.videoName, int(data["WindowsList"][i]["X"]), int(data["WindowsList"][i]["Y"]))
i+=1
while True:
try:
......
{
"WindowsList": [
{
"X": "0",
"Y": "0",
"width": "960",
"height": "1200"
},
{
"X": "961",
"Y": "0",
"width": "960",
"height": "1200"
},
{
"X": "20",
"Y": "20",
"width": "640",
"height": "480"
},
{
"X": "30",
"Y": "30",
"width": "640",
"height": "480"
}
]
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment