Changeset - f85a79f2fd95
[Not reviewed]
default
0 3 1
Laman - 8 years ago 2017-02-28 20:18:20

added JSON config file
4 files changed with 21 insertions and 3 deletions:
0 comments (0 inline, 0 general)
.hgignore
Show inline comments
 
__pycache__/
 
^\.idea/
 
^images/
 
^config.json$
config.json.template
Show inline comments
 
new file 100644
 
{
 
	"misc": {
 
		"defaultImage": "1.jpg"
 
	},
 
	"gui": {
 
		"showGrid": true,
 
		"showBigPoints": false
 
	}
 
}
src/config.py
Show inline comments
 
import os
 
import logging
 
import json
 

	
 

	
 
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=logging.DEBUG)
 
with open(os.path.join(os.path.dirname(__file__), "..", "config.json")) as f:
 
	cfgFile=json.load(f)
 

	
 
class misc:
 
	file=cfgFile["misc"]
 
	version=(0,0,0)
 
	defaultImage=file.get("defaultImage", "1.jpg")
 

	
 
class gui:
 
	showBigPoints=True
 
	showGrid=False
 
	file=cfgFile["gui"]
 
	showBigPoints=file.get("showBigPoints", False)
 
	showGrid=file.get("showGrid", True)
src/core.py
Show inline comments
 
import os
 
import multiprocessing
 
import threading
 
import logging as log
 
import PIL
 
from util import MsgQueue
 
from gui import gui
 
from imageanalyzer import ImageAnalyzer
 
from go import Go
 
import config as cfg
 

	
 

	
 
class Core:
 
	def __init__(self):
 
		self.grid=None
 
		self.go=Go()
 
		self.detector=ImageAnalyzer()
 

	
 
		self._ownMessages=MsgQueue(self._handleEvent)
 
		self._guiMessages=MsgQueue()
 

	
 
		imgPath=os.path.join(os.path.dirname(__file__), "..","images","5.jpg")
 
		imgPath=os.path.join(os.path.dirname(__file__), "..","images",cfg.misc.defaultImage)
 
		self._frame=PIL.Image.open(imgPath)
 

	
 
		self._guiProc=multiprocessing.Process(name="gui", target=gui, args=(self._guiMessages,self._ownMessages))
 
		self._guiProc.start()
 
		self._guiMessages.send("setCurrentFrame",(self._frame.copy(),))
 

	
 
	def setCorners(self,corners):
 
		self.detector.setGridCorners(corners)
 
		self.detector.analyze(self._frame)
 
		self._guiMessages.send("setGameState",(self.detector.board,))
 

	
 
	def setTresholds(self,tresB=None,tresW=None):
0 comments (0 inline, 0 general)