[mousetrap] Fixed Makefiles
- From: Flavio Percoco <flaper src gnome org>
- To: svn-commits-list gnome org
- Subject: [mousetrap] Fixed Makefiles
- Date: Sat, 27 Jun 2009 21:16:16 +0000 (UTC)
commit 10df3173e45d79a74eefbcc6fddc28d68b92dd31
Author: Flavio Percoco Premoli <flaper87 gmail com>
Date: Thu Jun 25 17:26:09 2009 +0200
Fixed Makefiles
.gitignore | 1 +
dev_tools/idm_example.py | 7 +++++++
src/mousetrap/addons/cpu.py | 2 ++
src/mousetrap/addons/handler.py | 11 +++++++++++
src/mousetrap/debug.py | 9 ++++++++-
src/mousetrap/lib/mouse.py | 2 +-
src/mousetrap/mousetrap.py | 4 ++++
src/mousetrap/ui/main.py | 8 ++++++++
src/ocvfw/idm/eyes.py | 7 +++++++
src/ocvfw/idm/forehead.py | 9 +++++++++
10 files changed, 58 insertions(+), 2 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 6bc1ff5..a1d6b6e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ i18n.py
compile
*.patch
*~
+*.swp
diff --git a/dev_tools/idm_example.py b/dev_tools/idm_example.py
index 375afd3..869d47c 100644
--- a/dev_tools/idm_example.py
+++ b/dev_tools/idm_example.py
@@ -27,6 +27,7 @@ __date__ = "$Date$"
__copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
__license__ = "GPLv2"
+import ocvfw.debug as debug
import ocvfw.commons as commons
from ocvfw.dev.camera import Camera, Capture, Point
@@ -53,6 +54,8 @@ class Module(object):
- controller: mousetrap main class pointer. This is passed by MouseTrap's controller (mousetrap.py) when loaded.
- stgs: Possible settings loaded from the user's settings file. If there aren't settings the IDM will use the a_settings dict.
"""
+ # Debugging is always important
+ debug.debug("ocvfw.idm", "Starting %s idm" % a_name)
# This will init the Camera class.
# This class is used to handle the camera device.
@@ -71,6 +74,8 @@ class Module(object):
# Prepares the IDM using the settings.
self.prepare_config()
+
+ debug.info("ocvfw.idm", "%s Algorithm loaded" % a_name)
def prepare_config(self):
"""
@@ -99,6 +104,8 @@ class Module(object):
- cam: The camera device index. For Example: 0 = /dev/video0, 1 = /dev/video1
"""
+ debug.debug("ocvfw.idm", "Setting Capture")
+
# Starts the Capture using the async method.
# This means that self.cap.sync() wont be called periodically
# by the idm because the Capture syncs the image asynchronously (See dev/camera.py)
diff --git a/src/mousetrap/addons/cpu.py b/src/mousetrap/addons/cpu.py
index 7c59384..7c96370 100644
--- a/src/mousetrap/addons/cpu.py
+++ b/src/mousetrap/addons/cpu.py
@@ -20,6 +20,7 @@
import os
import gobject
+import mousetrap.debug as debug
import mousetrap.environment as env
from subprocess import Popen, PIPE
@@ -35,6 +36,7 @@ class Addon(AddonsBase):
AddonsBase.__init__(self, controller)
gobject.timeout_add(1000, self.check_cpu)
+ debug.debug("addon.cpu", "CPU addon started")
def check_cpu(self):
"""
diff --git a/src/mousetrap/addons/handler.py b/src/mousetrap/addons/handler.py
index 4078995..62331c7 100644
--- a/src/mousetrap/addons/handler.py
+++ b/src/mousetrap/addons/handler.py
@@ -73,6 +73,7 @@ class AddonsBase(object):
"""
self.ctr = controller
+ self.cfg = controller.cfg
self.itf = self.ctr.itf
def statusbar_message(self, msg):
@@ -84,3 +85,13 @@ class AddonsBase(object):
- msg: The message.
"""
self.itf.statusbar.push(self.itf.statusbar_id, msg)
+
+ def add_item(self, item):
+ """
+ Adds any gtk widget to the addons vbox.
+
+ Arguments:
+ - self: The main object pointer.
+ - item: The item to add.
+ """
+ self.itf.adds_vbox.pack_start(item, True, True)
diff --git a/src/mousetrap/debug.py b/src/mousetrap/debug.py
index 5770641..50521c4 100644
--- a/src/mousetrap/debug.py
+++ b/src/mousetrap/debug.py
@@ -31,6 +31,13 @@ import logging
modules = {}
+
+class StreamFileHandler(logging.Handler):
+
+ def emit(self, record):
+ final_msg = "%s: %s - %s" % (record.levelname, record.name, record.getMessage())
+ print(final_msg)
+
def checkModule( module ):
"""
Get's a new logger for modules.
@@ -43,7 +50,7 @@ def checkModule( module ):
formatter = logging.Formatter("%(levelname)s: %(name)s -> %(message)s")
- cli = logging.StreamHandler( )
+ cli = StreamFileHandler( )
cli.setLevel( level )
cli.setFormatter(formatter)
diff --git a/src/mousetrap/lib/mouse.py b/src/mousetrap/lib/mouse.py
index 0b4b0d7..9f637df 100644
--- a/src/mousetrap/lib/mouse.py
+++ b/src/mousetrap/lib/mouse.py
@@ -53,7 +53,7 @@ xDisplay = display.Display()
isGnome = False
if env.desktop == "gnome":
isGnome = True
- debug.debug( "mousetrap.mouse", "GNOME desktop has been detected" )
+ debug.info( "mousetrap.mouse", "GNOME desktop has been detected" )
## pyatspi registry for gnome users
reg = pyatspi.Registry
diff --git a/src/mousetrap/mousetrap.py b/src/mousetrap/mousetrap.py
index 898dd73..8671f4a 100644
--- a/src/mousetrap/mousetrap.py
+++ b/src/mousetrap/mousetrap.py
@@ -37,6 +37,7 @@ import sys
sys.argv[0] = "mousetrap"
import gobject
+import debug
from ocvfw import pocv
from ui.main import MainGui
from ui.scripts.screen import ScriptClass
@@ -85,11 +86,14 @@ class Controller():
gobject.timeout_add(150, self.update_frame)
gobject.timeout_add(50, self.update_pointers)
+
+ debug.info("mousetrap", "Idm loaded and started")
# Lets build the interface
self.itf = MainGui(self)
self.itf.build_interface()
self.itf.load_addons()
+ debug.info("mousetrap", "MouseTrap's Interface Builded and Loaded")
gobject.threads_init()
self.loop.run()
diff --git a/src/mousetrap/ui/main.py b/src/mousetrap/ui/main.py
index d7b3557..e0ae56f 100644
--- a/src/mousetrap/ui/main.py
+++ b/src/mousetrap/ui/main.py
@@ -109,6 +109,10 @@ class MainGui( gtk.Window ):
self.vBox.pack_start( self.buttonsBox, False, False )
+ self.adds_vbox = gtk.VBox()
+ self.adds_vbox.show_all()
+ self.vBox.pack_start( self.adds_vbox, False, False )
+
self.cap_image = gtk.Image()
if self.cfg.getboolean("gui", "showCapture"):
@@ -146,6 +150,9 @@ class MainGui( gtk.Window ):
self.vBox.show_all()
self.add(self.vBox)
self.show()
+
+ debug.debug("ui.main", "Interface Builded")
+
def load_addons(self):
"""
@@ -160,6 +167,7 @@ class MainGui( gtk.Window ):
globals(), locals(),[''])
setattr(self, add, tmp.Addon(self.ctr))
+ debug.debug("ui.main", "Addons loaded")
def update_frame(self, img, point):
diff --git a/src/ocvfw/idm/eyes.py b/src/ocvfw/idm/eyes.py
index 6dc7662..6380164 100644
--- a/src/ocvfw/idm/eyes.py
+++ b/src/ocvfw/idm/eyes.py
@@ -28,6 +28,7 @@ __copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
__license__ = "GPLv2"
import pyvision as pv
+import ocvfw.debug as debug
import ocvfw.commons as commons
from ocvfw.dev.camera import Camera, Capture, Point
from pyvision.face.FilterEyeLocator import loadFilterEyeLocator as eye_locator
@@ -54,6 +55,8 @@ class Module(object):
- controller: mousetrap main class pointer. This is passed by MouseTrap's controller (mousetrap.py) when loaded.
- stgs: Possible settings loaded from the user's settings file. If there aren't settings the IDM will use the a_settings dict.
"""
+ debug.debug("ocvfw.idm", "Starting %s idm" % a_name)
+
Camera.init()
self.img = None
@@ -79,6 +82,7 @@ class Module(object):
self.isMoving = False
self.prepare_config()
+ debug.info("ocvfw.idm", "Forhead Algorithm loaded")
def prepare_config(self):
"""
@@ -100,6 +104,9 @@ class Module(object):
- self: The main object pointer
- cam: The camera device index. For Example: 0 = /dev/video0, 1 = /dev/video1
"""
+
+ debug.debug("ocvfw.idm", "Setting Capture")
+
self.cap = Capture(async=False, idx=cam)
self.cap.change(color="rgb")
diff --git a/src/ocvfw/idm/forehead.py b/src/ocvfw/idm/forehead.py
index d3a8288..9a8763c 100644
--- a/src/ocvfw/idm/forehead.py
+++ b/src/ocvfw/idm/forehead.py
@@ -27,6 +27,7 @@ __date__ = "$Date$"
__copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
__license__ = "GPLv2"
+import ocvfw.debug as debug
import ocvfw.commons as commons
from ocvfw.dev.camera import Camera, Capture, Point
@@ -48,6 +49,9 @@ class Module(object):
- controller: mousetrap main class pointer. This is passed by MouseTrap's controller (mousetrap.py) when loaded.
- stgs: Possible settings loaded from the user's settings file. If there aren't settings the IDM will use the a_settings dict.
"""
+
+ debug.debug("ocvfw.idm", "Starting %s idm" % a_name)
+
Camera.init()
self.ctr = controller
@@ -78,6 +82,7 @@ class Module(object):
self.isMoving = False
self.prepare_config()
+ debug.info("ocvfw.idm", "Forhead Algorithm loaded")
def prepare_config(self):
"""
@@ -99,9 +104,13 @@ class Module(object):
- self: The main object pointer
- cam: The camera device index. For Example: 0 = /dev/video0, 1 = /dev/video1
"""
+
+ debug.debug("ocvfw.idm", "Setting Capture")
+
self.cap = Capture(async=True, idx=cam)
self.cap.change(color="rgb")
+
def calc_motion(self):
if not hasattr(self.cap, "forehead"):
self.get_forehead()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]