diff --git a/src/core.py b/src/core.py --- a/src/core.py +++ b/src/core.py @@ -20,12 +20,12 @@ class Core: self._ownMessages=MsgQueue(self._handleEvent) self._guiMessages=MsgQueue() - imgPath=os.path.join(os.path.dirname(__file__), "..","images","7.jpg") + imgPath=os.path.join(os.path.dirname(__file__), "..","images","5.jpg") 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,)) + self._guiMessages.send("setCurrentFrame",(self._frame.copy(),)) def setCorners(self,corners): self.detector.setGridCorners(corners) @@ -44,7 +44,7 @@ class Core: def joinGui(self): self._guiProc.join() - self._ownMessages.send("kill") + self._ownMessages.send("!kill") def _handleEvent(self,e): actions={"setCorners":self.setCorners, "setTresholds":self.setTresholds} diff --git a/src/gui/mainwindow.py b/src/gui/mainwindow.py --- a/src/gui/mainwindow.py +++ b/src/gui/mainwindow.py @@ -33,15 +33,16 @@ class MainWindow(tk.Frame): w=int(self.imgView['width']) h=int(self.imgView['height']) - self.img=ImageTk.PhotoImage(frame.resize((w,h),resample=PIL.Image.BILINEAR)) - - wo,ho=self.currentFrame.size # o for original + wo,ho=frame.size # o for original widthRatio=wo/w heightRatio=ho/h self._imgSizeCoef=max(widthRatio,heightRatio) # shift compensates possible horizontal or vertical empty margins from unmatching aspect ratios self._imgShift=EPoint(wo-w*self._imgSizeCoef,ho-h*self._imgSizeCoef)/2 + frame.thumbnail((w,h)) # resize + self.img=ImageTk.PhotoImage(frame) + def _createWidgets(self): # a captured frame with overlay graphics self.imgView=tk.Canvas(self) @@ -69,6 +70,8 @@ class MainWindow(tk.Frame): ## Stores a grid corner located at x,y coordinates. def addCorner(self,x,y): self.corners.add(x,y) + log.debug("click on %d,%d",x,y) + log.debug("sizeCoef: %f, shift: %d,%d",self._imgSizeCoef,self._imgShift.x,self._imgShift.y) if self.corners.canonizeOrder(): # transform corners from show coordinates to real coordinates log.debug(self.corners.corners) @@ -81,7 +84,7 @@ class MainWindow(tk.Frame): ## Redraws the current image and its overlay. def redrawImgView(self): if self.currentFrame and self.img: - self.imgView.create_image(2,2,anchor="nw",image=self.img) + self.imgView.create_image(240,180,anchor="center",image=self.img) for corner in self.corners.corners: self.markPoint(corner.x,corner.y) diff --git a/src/util.py b/src/util.py --- a/src/util.py +++ b/src/util.py @@ -22,7 +22,7 @@ class MsgQueue: if self._queue.empty(): self._event.clear() log.info(msg) - if msg[0]=="kill": break + if msg[0]=="!kill": break self._handleEvent(msg) def setHandler(self,handler):