MouseTrap Status

From Foss2Serve
(Difference between revisions)
Jump to: navigation, search
m
m
 
(204 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 +
{|align=right
 +
  |__TOC__
 +
  |}
 +
 +
DEVELOPMENT HELP PAGE: http://xcitegroup.org/foss2serve/index.php/MouseTrap_Dev_Help (includes opencv status)
 +
 +
=INSTALLED PACKAGES=
 
Please state the versions and OS you are currently working with so that versioning errors can be ruled out.
 
Please state the versions and OS you are currently working with so that versioning errors can be ruled out.
 
{| border="1" class="wikitable"
 
{| border="1" class="wikitable"
! Team Member Name
+
! Team Member Name || Installed Packages
! Installed packages
+
! Team Member Name || Installed Packages
 
|-
 
|-
|Amber
+
|Amber (8/5/2013)
 +
|
 +
{| border="1" class="wikitable"
 +
! Package Name
 +
! Version
 +
 
 +
|-
 +
|Fedora
 +
|19
 +
 
 +
|-
 +
|Gnome
 +
|3.8.2
 +
 
 +
|-
 +
|Python
 +
|2.7.5
 +
 
 +
|-
 +
|gtk3
 +
|3.8.2
 +
 
 +
|-
 +
|pygtk2
 +
|2.24.0
 +
 
 +
|-
 +
|opencv
 +
|2.4.5
 +
 
 +
|-
 +
|python-xlib
 +
|0.15
 +
 
 +
|-
 +
|at-spi-python
 +
|1.32.0
 +
 
 +
|-
 +
|gnome-common
 +
|3.7.4
 +
 
 +
|-
 +
|glib2-devel (libglib2.0-dev)
 +
|2.36.3
 +
 
 +
|-
 +
|intltool
 +
|0.50.2
 +
|}
 +
 
 +
 
 +
 
 +
|Logan
 
|
 
|
 
{| border="1" class="wikitable"
 
{| border="1" class="wikitable"
Line 50: Line 110:
 
|2.32.4
 
|2.32.4
  
 +
|-
 +
|doxygen
 +
|1.8.1
 +
 +
|-
 +
|intltool
 +
|0.50
  
 
|}
 
|}
 +
 
|-
 
|-
|ALogan
+
|John
 +
|
 +
{| border="1" class="wikitable"
 +
! Package Name
 +
! Version
 +
 
 +
|-
 +
|Fedora
 +
|18
 +
 
 +
|-
 +
|Gnome
 +
|2.30.2
 +
 
 +
|-
 +
|Python
 +
|2.6.5-0ubuntu1
 +
 
 +
|-
 +
|gtk2
 +
|2.20.1-0ubuntu2.1
 +
 
 +
|-
 +
|pygtk2
 +
|???
 +
 
 +
|-
 +
|opencv
 +
|2.0.0-3ubuntu2
 +
 
 +
|-
 +
|python-xlib
 +
|0.14+20091101-1
 +
 
 +
|-
 +
|at-spi-python (python-pyspi)
 +
|not installed
 +
 
 +
|-
 +
|gnome-common
 +
|2.28.0-1
 +
 
 +
|-
 +
|glib2-devel (libglib2.0-dev)
 +
|2.32.4
 +
 
 +
|-
 +
|doxygen
 +
|1.8.1
 +
 
 +
|-
 +
|intltool
 +
|0.41.0-0ubuntu1
 +
 
 +
|}
 +
 
 +
 
 +
|Nicole
 
|
 
|
 
{| border="1" class="wikitable"
 
{| border="1" class="wikitable"
Line 72: Line 197:
  
 
|-
 
|-
|gtk2
+
|gtk2 (version 3 breaks api)
|2.24.13
+
|2.4.13
  
 
|-
 
|-
Line 80: Line 205:
  
 
|-
 
|-
|opencv
+
|opencv (cv)
 
|2.3.1
 
|2.3.1
  
Line 92: Line 217:
  
 
|-
 
|-
|gnome-common -x
+
|gnome-common
 
|3.4.0.1
 
|3.4.0.1
  
 
|-
 
|-
|glib2-devel (libglib2.0-dev) -x
+
|glib2-devel (libglib2.0-dev)
 
|2.32.4
 
|2.32.4
  
 
|-
 
|-
|doxygen
+
|intltool
|1.8.1
+
|0.50.2
 +
|}
  
  
 
|}
 
|}
  
|}
+
=STATUS=
 +
Please enter the status of the ongoing project below
  
 +
==Stoney Status==
 +
Stoney is documenting his efforts on his blog: http://stoney-jackson.blogspot.com/
  
Please enter the status of the ongoing project below
+
<div>
{| border="1" class="wikitable"
+
==Amber Status==
! Name
+
{| class="mw-collapsible mw-collapsed wikitable"
! Date
+
!Status 2012
! Entry
+
|-
|-style="font-style: italic; background-color: #FFCCFF;"
+
|
|Amber
+
===12.10.2012===
| 12.10.2012 || Full install of mousetrap complete. Config file was manipulated to include failed dependency on 'python-opencv' which has been updated and the package is now referred to as 'cv'. Other dependencies are outdated or the names have been changed as well (xlib-python, etc). New errors with 'gobject' have been identified. Here is the recorded error when running mousetrap:  
+
Full install of mousetrap complete. Config file was manipulated to include failed dependency on 'python-opencv' which has been updated and the package is now referred to as 'cv'. Other dependencies are outdated or the names have been changed as well (xlib-python, etc). New errors with 'gobject' have been identified. Here is the recorded error when running mousetrap:  
  
  
Line 143: Line 272:
 
   mousetrap/ocvfw/dev/camera.py
 
   mousetrap/ocvfw/dev/camera.py
  
|-style="font-style: italic; background-color: #FFCCFF;"
+
 
|Amber
+
===12.11.2012===
|12.11.2012 ||New error is present:
+
New error is present:
 
   /usr/lib/python2.7/site-packages/gobject/constants.py:24:
 
   /usr/lib/python2.7/site-packages/gobject/constants.py:24:
 
   Warning: g_boxed_type_register_static: assertion `g_type_from_name(name) == 0' failed
 
   Warning: g_boxed_type_register_static: assertion `g_type_from_name(name) == 0' failed
Line 182: Line 311:
 
     [''])
 
     [''])
 
Will attempt to remove instances of broken dependency opencv to the newer cv
 
Will attempt to remove instances of broken dependency opencv to the newer cv
 +
* Fix: replace the "opencv.cv" in _ocv.py on line 290 with "cv"
  
 +
===12.17.2012===
 +
Bug for pygobject is here: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=649861
 +
 +
*The fix is to upgrade to version 3 of gtk?
 +
*Changed line in configure.in file to AM_CHECK_PYMOD(cv,,,[AC_MSG_ERROR(Could not find python module cv)]) to fix opencv problem when creating make files
 +
*Highgui no longer exists in the new API for cv (once known as opencv) and it should just be called as cv.whatever.
 +
*cvCreateCameraCapture() no longer exists, replaced with cv.CaptureFromCAM().
 +
 +
'''New Error'''
 +
  /usr/lib/python2.7/site-packages/gobject/constants.py:24:
 +
  Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
 +
  import gobject._gobject
 +
  DEBUG: mousetrap.ocvfw.idm -> Starting Forehead idm
 +
  INFO: mousetrap.ocvfw.idm -> Forhead Algorithm loaded
 +
  DEBUG: mousetrap.ocvfw.idm -> Setting Capture
 +
  DEBUG: Commons -> New Singleton Add (mousetrap.ocvfw.dev.camera.Camera)
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  DEBUG: ocvfw -> cmStartCamera: Camera Started
 +
  DEBUG: Camera -> Loaded backend OcvfwPython
 +
  DEBUG: OcvfwBase -> Changed lk_swap value to True
 +
  INFO: mousetrap - Idm loaded and started
 +
  Traceback (most recent call last):
 +
  File "<string>", line 1, in <module>
 +
  File "mousetrap/app/main.py", line 101, in start
 +
    self.itf = MainGui(self)
 +
  File "mousetrap/app/ui/main.py", line 54, in __init__
 +
    self.script = self.ctr.script()
 +
  File "mousetrap/app/main.py", line 229, in script
 +
    return get_script_class(self.cfg.get("scripts", "name"))()
 +
  File "mousetrap/app/ui/scripts/__init__.py", line 45, in get_script_class
 +
    script = __import__(script_name, globals(), locals())
 +
  File "mousetrap/app/ui/scripts/joystick.py", line 36, in <module>
 +
    from ..widgets import Mapper
 +
  File "mousetrap/app/ui/widgets.py", line 236, in <module>
 +
    GObject.type_register(Mapper)
 +
  TypeError: argument must be a GObject subclass
 +
 +
Will look into gtk and GObject for error
 +
 +
 +
===12.19.2012===
 +
 +
*In this particular file: widgets.py, we actually want to import gobject directly and type_register the Mapper using gobject. After doing this, I have the Window pop up and now a new error has come up.
 +
 +
'''New Error'''
 +
  /usr/lib/python2.7/site-
 +
  packages/gobject/constants.py:24: Warning:
 +
  g_boxed_type_register_static: assertion
 +
  `g_type_from_name (name) == 0' failed
 +
  import gobject._gobject
 +
  DEBUG: mousetrap.ocvfw.idm -> Starting Forehead idm
 +
  INFO: mousetrap.ocvfw.idm -> Forhead Algorithm loaded
 +
  DEBUG: mousetrap.ocvfw.idm -> Setting Capture
 +
  DEBUG: Commons -> New Singleton Add 
 +
  (mousetrap.ocvfw.dev.camera.Camera)
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  DEBUG: ocvfw -> cmStartCamera: Camera Started
 +
  DEBUG: Camera -> Loaded backend OcvfwPython
 +
  DEBUG: OcvfwBase -> Changed lk_swap value to True
 +
  INFO: mousetrap - Idm loaded and started
 +
  DEBUG: ui.main - Interface Built
 +
  DEBUG: ui.main - Addons loaded
 +
  INFO: mousetrap - MouseTrap's Interface Built and 
 +
  Loaded
 +
  Traceback (most recent call last):
 +
  File "mousetrap/ocvfw/dev/camera.py", line 116, in sync
 +
    Camera.query_image()
 +
  File "mousetrap/ocvfw/_ocv.py", line 125, in query_image
 +
    frame = co.hg.cvQueryFrame( self.capture )
 +
  AttributeError: 'module' object has no attribute 'cvQueryFrame'
 +
  Traceback (most recent call last):
 +
  File "mousetrap/app/main.py", line 238, in update_frame
 +
    self.itf.update_frame(self.idm.get_capture(),  self.idm.get_pointer())
 +
  File "mousetrap/ocvfw/idm/forehead.py", line 128,  in get_capture
 +
    self.get_forehead()
 +
  File "mousetrap/ocvfw/idm/forehead.py", line 148, in get_forehead
 +
    face    =  self.cap.get_area(commons.haar_cds['Face'])
 +
  File "mousetrap/ocvfw/dev/camera.py", line 373, in get_area
 +
    return Camera.get_haar_points(haar_csd)
 +
  File "mousetrap/ocvfw/_ocv.py", line 335, in get_haar_points
 +
    cascade = co.cv.cvLoadHaarClassifierCascade( haarCascade, self.imgSize )
 +
  AttributeError: 'module' object has no attribute 'cvLoadHaarClassifierCascade'
 +
  /usr/local/bin/mousetrap: line 139:  6073  Segmentation fault      (core dumped)  /usr/bin/python -c "import mousetrap.app.main as  mousetrap; mousetrap.Controller().start();" "$ARGS"
 +
 +
*hg no longer exists. _ocv.py should be looked over for inconsistencies with new api
 +
*Changed line 125 in _ocv.py to frame = co.hg.QueryFrame( self.capture )
 +
  _ocv needs to change many dependencies for the new api
 +
*Changed import in widgets.py to 'import gobject' and changed to 'gobject.register_type(Mapper)'
 +
 +
I have no other error besides this:
 +
  /usr/lib/python2.7/site-  packages/gobject/constants.py:24: Warning:  g_boxed_type_register_static: assertion  `g_type_from_name (name) == 0' failed
 +
  import gobject._gobject
 +
and this:
 +
  (mousetrap:19550): Gtk-WARNING **: Unable to locate theme engine in module_path: "clearlooks",
 +
 +
 
 +
I believe this is explained in this reported bug: https://bugs.launchpad.net/bzr-gtk/+bug/923824
 +
* There is a whole big issue with dependencies surrounding pygobject, pygtk, and gtk that are causing errors.
 +
 +
 +
===12.20.2012===
 +
Looked into error with pygobject, gtk and pygtk and found that the import gi must be the first import in main.py
 
|}
 
|}
  
 +
{| border="1" class="mw-collapsible mw-collapsed wikitable"
 +
! Status Jan-Aug 2013
 +
|-
 +
|
 +
===1.7.2013===
 +
 +
'''New error'''
 +
  /usr/lib/python2.7/site-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
 +
  import gobject._gobject
 +
  DEBUG: mousetrap.ocvfw.idm -> Starting Forehead idm
 +
  INFO: mousetrap.ocvfw.idm -> Forhead Algorithm loaded
 +
  DEBUG: mousetrap.ocvfw.idm -> Setting Capture
 +
  DEBUG: Commons -> New Singleton Add (mousetrap.ocvfw.dev.camera.Camera)
 +
  CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate production trees: Can't create any  node of the requested type!
 +
  DEBUG: ocvfw -> cmStartCamera: Camera Started
 +
  DEBUG: Camera -> Loaded backend OcvfwPython
 +
  DEBUG: OcvfwBase -> Changed lk_swap value to True
 +
  INFO: mousetrap - Idm loaded and started
 +
  DEBUG: ui.main - Interface Built
 +
  DEBUG: ui.main - Addons loaded
 +
  INFO: mousetrap - MouseTrap's Interface Built and Loaded
 +
  /usr/local/bin/mousetrap: line 139:  3335 Segmentation fault      (core dumped) /usr/bin/python -c "import mousetrap.app.main as mousetrap; mousetrap.Controller().start();" "$ARGS"
 +
 +
===1.8.2013===
 +
Error:
 +
  File "mousetrap/ocvfw/_ocv.py", line 332, in get_haar_points
 +
  cascade = co.cv.CvLoadHaarClassifierCascade( haarCascade, self.imgSize )
 +
  AttributeError: 'module' object has no attribute 'CvLoadHaarClassifierCascade'
 +
Fix::
 +
*LoadHaarClassifier -> Load
 +
 +
Error:
 +
  File "mousetrap/ocvfw/_ocv.py", line 332, in get_haar_points
 +
  cascade = co.cv.Load( haarCascade, self.imgSize )
 +
  AttributeError: Camera instance has no attribute 'imgSize'
 +
Fix:
 +
*imgSize -> removed
 +
 +
Error:
 +
  File "mousetrap/ocvfw/_ocv.py", line 337, in get_haar_points
 +
  co.cv.Resize( self.img, self.small_img, co.cv.CV_INTER_LINEAR )
 +
  AttributeError: Camera instance has no attribute 'small_img'
 +
 +
Fix:
 +
*Resize -> cvResize | cvResize -> OK
 +
 +
 +
 +
Receiving new error (same as Logan)
 +
  /usr/lib/python2.7/site-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name)  == 0' failed
 +
  import gobject._gobject
 +
  DEBUG: mousetrap.ocvfw.idm -> Starting Forehead idm
 +
  INFO: mousetrap.ocvfw.idm -> Forhead Algorithm loaded
 +
  DEBUG: mousetrap.ocvfw.idm -> Setting Capture
 +
  DEBUG: Commons -> New Singleton Add (mousetrap.ocvfw.dev.camera.Camera)
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  DEBUG: ocvfw -> cmStartCamera: Camera Started
 +
  DEBUG: Camera -> Loaded backend OcvfwPython
 +
  DEBUG: OcvfwBase -> Changed lk_swap value to True
 +
  INFO: mousetrap - Idm loaded and started
 +
  DEBUG: ui.main - Interface Built
 +
  DEBUG: ui.main - Addons loaded
 +
  Problems loading mousetrap.ocvfw.idm.eyes
 +
  INFO: mousetrap - MouseTrap's Interface Built and Loaded
 +
  Traceback (most recent call last):
 +
  File "mousetrap/ocvfw/dev/camera.py", line 116, in sync
 +
    Camera.query_image()
 +
  File "mousetrap/ocvfw/_ocv.py", line 127, in query_image
 +
    self.img            = co.cv.cvCreateImage ( self.imgSize, 8, 3 )
 +
  AttributeError: 'module' object has no attribute 'cvCreateImage'
 +
  Traceback (most recent call last):
 +
  File "mousetrap/app/main.py", line 238, in update_frame
 +
    self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 +
  File "mousetrap/ocvfw/idm/forehead.py", line 128, in get_capture
 +
    self.get_forehead()
 +
  File "mousetrap/ocvfw/idm/forehead.py", line 148, in get_forehead
 +
    face    = self.cap.get_area(commons.haar_cds['Face'])
 +
  File "mousetrap/ocvfw/dev/camera.py", line 373, in get_area
 +
    return Camera.get_haar_points(haar_csd)
 +
  File "mousetrap/ocvfw/_ocv.py", line 337, in get_haar_points
 +
    co.cv.Resize( self.img, self.small_img, co.cv.CV_INTER_LINEAR )
 +
  AttributeError: Camera instance has no attribute 'small_img'
 +
  /usr/local/bin/mousetrap: line 139:  8105 Segmentation fault      (core dumped) /usr/bin/python -c "import mousetrap.app.main as  mousetrap; mousetrap.Controller().start();" "$ARGS"
 +
 +
===1.9.2013===
 +
Looks like there are some inconsistencies with opencv. Going through and removing outdated methods. I was also looking to see how the camera is initiated, reading through code.
 +
 +
===1.11.2013===
 +
Was able to get rid of the small_img error after trying several adaptations of opencv methods.
 +
* cvSize no longer exists and the python tuple (int, int) should be used instead.
 +
Have new error:
 +
  Traceback (most recent call last):
 +
  File "mousetrap/app/main.py", line 238, in update_frame
 +
    self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 +
  File "mousetrap/ocvfw/idm/forehead.py", line 128, in get_capture
 +
    self.get_forehead()
 +
  File "mousetrap/ocvfw/idm/forehead.py", line 148, in get_forehead
 +
    face    = self.cap.get_area(commons.haar_cds['Face'])
 +
  File "mousetrap/ocvfw/dev/camera.py", line 373, in get_area
 +
    return Camera.get_haar_points(haar_csd)
 +
  File "mousetrap/ocvfw/_ocv.py", line 350, in get_haar_points
 +
    co.cv.ClearMemStorage( self.storage )
 +
  AttributeError: 'module' object has no attribute 'ClearMemStorage'
 +
  /usr/local/bin/mousetrap: line 139:  6550 Segmentation fault      (core dumped) /usr/bin/python -c "import mousetrap.app.main as  mousetrap; mousetrap.Controller().start();" "$ARGS"
 +
 +
*ClearMemStorage does not need to be performed because of upgrades to opencv api. See http://opencv-users.1802565.n2.nabble.com/Why-is-cvClearMemStorage-not-exposed-through-the-Python-interface-td7229752.html
 +
 +
New error:
 +
 +
  Traceback (most recent call last):
 +
  File "mousetrap/app/main.py", line 238, in update_frame
 +
    self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 +
  File "mousetrap/app/ui/main.py", line 186, in update_frame
 +
    self.cap_image.set_from_pixbuf(cap.to_gtk_buff().scale_simple(200, 160, gtk.gdk.INTERP_BILINEAR))
 +
  File "mousetrap/ocvfw/dev/camera.py", line 194, in to_gtk_buff
 +
    buff = gtk.gdk.pixbuf_new_from_data(img.imageData,
 +
  AttributeError: 'cv2.cv.iplimage' object has no attribute 'imageData'
 +
  DEBUG: ocvfw -> <iplimage(nChannels=1 width=640 height=480 widthStep=640 )>
 +
  DEBUG: ocvfw -> <iplimage(nChannels=1 width=640 height=480 widthStep=640 )>
 +
  DEBUG: ocvfw -> <iplimage(nChannels=1 width=640 height=480 widthStep=640 )>
 +
  DEBUG: ocvfw -> <iplimage(nChannels=1 width=640 height=480 widthStep=640 )>
 +
  /usr/local/bin/mousetrap: line 139:  6816 Segmentation fault      (core dumped) /usr/bin/python -c "import mousetrap.app.main as mousetrap; mousetrap.Controller().start();" "$ARGS"
 +
 +
 +
===1.14.2013===
 +
New error:
 +
 +
  /usr/lib/python2.7/site-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
 +
  import gobject._gobject
 +
  DEBUG: Ocvfw -> <module 'mousetrap.ocvfw.idm.forehead' from 'mousetrap/ocvfw/idm/forehead.pyc'>
 +
  DEBUG: mousetrap.ocvfw.idm -> Starting Forehead idm
 +
  INFO: mousetrap.ocvfw.idm -> Forhead Algorithm loaded
 +
  DEBUG: mousetrap.ocvfw.idm -> Setting Capture
 +
  DEBUG: Commons -> New Singleton Add (mousetrap.ocvfw.dev.camera.Camera)
 +
  CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate production trees: Can't create any node of the requested type!
 +
  ^^^^^^^^^^^^^^^^^^^^^^^^
 +
  DEBUG: ocvfw -> cmStartCamera: Camera Started
 +
  DEBUG: Camera -> Loaded backend OcvfwPython
 +
  DEBUG: ocvfw -> None
 +
  DEBUG: OcvfwBase -> Changed lk_swap value to True
 +
  INFO: mousetrap - Idm loaded and started
 +
  DEBUG: ui.main - Interface Built
 +
  DEBUG: ui.main - Addons loaded
 +
  INFO: mousetrap - MouseTrap's Interface Built and Loaded
 +
  /usr/local/bin/mousetrap: line 139:  5613 Segmentation fault      (core dumped) /usr/bin/python -c "import mousetrap.app.main as mousetrap; mousetrap.Controller().start();" "$ARGS"
 +
 +
New error:
 +
 +
  /usr/lib/python2.7/site-  packages/gobject/constants.py:24: Warning:  g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
 +
  import gobject._gobject
 +
  DEBUG: mousetrap.ocvfw.idm -> Starting Forehead idm
 +
  INFO: mousetrap.ocvfw.idm -> Forhead Algorithm  loaded
 +
  DEBUG: mousetrap.ocvfw.idm -> Setting Capture
 +
  DEBUG: Commons -> New Singleton Add    (mousetrap.ocvfw.dev.camera.Camera)
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  DEBUG: ocvfw -> cmStartCamera: Camera Started
 +
  DEBUG: Camera -> Loaded backend OcvfwPython
 +
  DEBUG: OcvfwBase -> Changed lk_swap value to True
 +
  INFO: mousetrap - Idm loaded and started
 +
  DEBUG: ui.main - Interface Built
 +
  DEBUG: ui.main - Addons loaded
 +
  INFO: mousetrap - MouseTrap's Interface Built and  Loaded
 +
  Help on iplimage object:
 +
  class iplimage(__builtin__.object)
 +
  Methods defined here:
 +
 
 +
  __delitem__(...)
 +
      x.__delitem__(y) <==> del x[y]
 +
 
 +
  __getitem__(...)
 +
      x.__getitem__(y) <==> x[y]
 +
 
 +
  __repr__(...)
 +
      x.__repr__() <==> repr(x)
 +
 
 +
  __setitem__(...)
 +
      x.__setitem__(i, y) <==> x[i]=y
 +
 
 +
  tostring(...)
 +
 
 +
  ----------------------------------------------------------------------
 +
  Data descriptors defined here:
 +
 
 +
  channels
 +
      nChannels
 +
 
 +
  depth
 +
      depth
 +
 
 +
  height
 +
      height
 +
 
 +
  nChannels
 +
    nChannels
 +
 
 +
  origin
 +
    origin
 +
 
 +
  width
 +
      width
 +
 
 +
  ----------------------------------------------------------------------
 +
  Data and other attributes defined here:
 +
 
 +
  __new__ = <built-in method __new__ of type object>
 +
      T.__new__(S, ...) -> a new object with type S, a subtype of T
 +
 +
  DEBUG: ui.main - None
 +
  DEBUG: ui.main -> None
 +
  Traceback (most recent call last):
 +
  File "mousetrap/app/main.py", line 238, in update_frame
 +
    self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 +
  File "mousetrap/app/ui/main.py", line 186, in update_frame
 +
        self.cap_image.set_from_pixbuf(cap.to_gtk_buff().sc  ale_simple(200, 160, gtk.gdk.INTERP_BILINEAR))
 +
  File "mousetrap/ocvfw/dev/camera.py", line 195, in to_gtk_buff
 +
    buff = gtk.gdk.pixbuf_new_from_data(img.data,
 +
  AttributeError: 'cv2.cv.iplimage' object has no  attribute 'data'
 +
  /usr/local/bin/mousetrap: line 139:  2209  Segmentation fault      (core dumped)  /usr/bin/python -c "import mousetrap.app.main as mousetrap; mousetrap.Controller().start();" "$ARGS"
 +
 +
 +
*Fix: replaced imageData with tostring()
 +
 +
===1.15.2013===
 +
New error:
 +
  Traceback (most recent call last):
 +
  File "mousetrap/app/main.py", line 238, in update_frame
 +
    self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 +
  File "mousetrap/app/ui/main.py", line 186, in update_frame
 +
    self.cap_image.set_from_pixbuf(cap.to_gtk_buff().scale_simple(200, 160, gtk.gdk.INTERP_BILINEAR))
 +
  File "mousetrap/ocvfw/dev/camera.py", line 198, in to_gtk_buff
 +
    img.widthStep )
 +
  AttributeError: 'cv2.cv.iplimage' object has no attribute 'widthStep'
 +
  /usr/local/bin/mousetrap: line 139:  3991 Segmentation fault      (core dumped) /usr/bin/python -c "import mousetrap.app.main as mousetrap; mousetrap.Controller().start();" "$ARGS"
 +
 +
*Fix widthStep does not exist, use width
 +
 +
 +
===1.16.2013===
 +
New Error:
 +
 +
  Traceback (most recent call last):
 +
  File "mousetrap/app/main.py", line 238, in update_frame
 +
    self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 +
  File "mousetrap/ocvfw/idm/forehead.py", line 127, in get_capture
 +
    self.get_forehead()
 +
  File "mousetrap/ocvfw/idm/forehead.py", line 147, in get_forehead
 +
    face    = self.cap.get_area(commons.haar_cds['Face'])
 +
  File "mousetrap/ocvfw/dev/camera.py", line 373, in get_area
 +
    return Camera.get_haar_points(haar_csd)
 +
  File "mousetrap/ocvfw/_ocv.py", line 350, in get_haar_points
 +
    for r in points]
 +
  AttributeError: 'module' object has no attribute 'Point'
 +
  /usr/local/bin/mousetrap: line 139:  4940 Segmentation fault      (core dumped) /usr/bin/python -c "import mousetrap.app.main as mousetrap; mousetrap.Controller().start();" "$ARGS"
 +
*Point no longer exists in the python version of the api. Now tuples are used. Looking into how the points are used in the program to see if it can be changed.
 +
 +
===1.17.2013===
 +
 +
* Mousetrap has its own internal class for Point, so it could be used instead of cvPoint.
 +
* Definition and explanation of optical flow: http://centeye.com/technology/optical-flow/
 +
* Found a good tutorial of optical flow here: http://dasl.mem.drexel.edu/~noahKuntz/openCVTut9.html
 +
* Mousetrap uses the Lucas-kanade method of detection (even though it is incorrect in the comments)
 +
* Here is the docs on motion detecting: http://docs.opencv.org/modules/video/doc/motion_analysis_and_object_tracking.html
 +
 +
===1.21.2013===
 +
* Fixed most of the Point errors; make sure cvPoint is just a python tuple
 +
* Load() is the new cvLoadHaarClassifierCascade()
 +
* The points variable in _ocv.py looks like this: ((173, 130, 145, 145), 15) but it is used as if it was a series of points, so that was changed to r[0][0] and so forth.
 +
 +
Some examples of point errors/changes:
 +
 +
'''Error'''
 +
  Traceback (most recent call last):
 +
  File "mousetrap/app/main.py", line 238, in update_frame
 +
    self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 +
  File "mousetrap/ocvfw/idm/forehead.py", line 127, in get_capture
 +
    self.get_forehead()
 +
  File "mousetrap/ocvfw/idm/forehead.py", line 163,  in get_forehead
 +
    areas = [ (pt[1].x - pt[0].x)*(pt[1].y - pt[0].y) for pt in eyes ]
 +
 +
'''Changes'''
 +
  if eyes:
 +
    areas = [ (pt[1][0] - pt[0][0])*(pt[1][1] - pt[0][1]) for pt in eyes ] #replaced x with [0] and y with [1]
 +
 +
===1.23.2013===
 +
New Error:
 +
  OpenCV Error: Incorrect size of input array () in cvGetSubRect, file /builddir/build/BUILD/OpenCV-2.3.1/modules/core/src/array.cpp, line 1262           
 +
  Traceback (most recent call last):                                         
 +
  File "mousetrap/app/main.py", line 238, in update_frame                   
 +
    self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())   
 +
  File "mousetrap/ocvfw/idm/forehead.py", line 127, in get_capture         
 +
    self.get_forehead()                                                     
 +
  File "mousetrap/ocvfw/idm/forehead.py", line 160, in get_forehead
 +
    "height" : endF[1] - startF[1]}, (startF[0], startF[1]) )# replaced x and y
 +
  File "mousetrap/ocvfw/dev/camera.py", line 378, in get_area
 +
    return Camera.get_haar_roi_points(haar_csd, roi, orig)
 +
  File "mousetrap/ocvfw/_ocv.py", line 378, in get_haar_roi_points
 +
    imageROI = co.cv.GetSubRect(self.img, rect)
 +
  cv2.error
 +
  * had to change some of the code for points, so this could have resulted from that, but I'm not sure what it's particularly building...any ideas?
 +
 +
The parameters of the self.image are: <iplimage(nChannels=3 width=640 height=480 widthStep=1920 )>
 +
 +
The rect parameters are: (318, 190, 205, 333)
 +
 +
* Maybe we can use the built in opencv method for tracking features? http://opencv.willowgarage.com/documentation/python/imgproc_feature_detection.html#goodfeaturestotrack
 +
 +
Getting Closer...
 +
* It is detecting objects and I have it printing the specs, so it's finding some..
 +
  DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
  DEBUG: ocvfw -> <iplimage(nChannels=3 width=640 height=480 widthStep=1920 )>
 +
  DEBUG: ocvfw -> (243, 192, 229, 280)
 +
  DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
  DEBUG: ocvfw -> <iplimage(nChannels=3 width=640 height=480 widthStep=1920 )>
 +
  DEBUG: ocvfw -> (237, 184, 243, 296)
 +
  DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
  DEBUG: ocvfw -> <iplimage(nChannels=3 width=640 height=480 widthStep=1920 )>
 +
  DEBUG: ocvfw -> (240, 186, 240, 294)
 +
  DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
  DEBUG: ocvfw -> <iplimage(nChannels=3 width=640 height=480 widthStep=1920 )>
 +
  DEBUG: ocvfw -> (243, 190, 234, 287)
 +
  DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
  DEBUG: ocvfw -> <iplimage(nChannels=3 width=640 height=480 widthStep=1920 )>
 +
  DEBUG: ocvfw -> (240, 189, 238, 289)
 +
  DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
  DEBUG: ocvfw -> <iplimage(nChannels=3 width=640 height=480 widthStep=1920 )>
 +
  DEBUG: ocvfw -> (241, 190, 234, 285)
 +
  DEBUG: ocvfw -> ((46, 71, 93, 43), 3)
 +
  DEBUG: ocvfw -> cmGetHaarROIPoints: detected some matches
 +
 +
Current error with optical flow:
 +
  optical_flow = co.cv.CalcOpticalFlowPyrLK (
 +
            self.prevGrey, self.grey, self.prevPyramid, self.pyramid,
 +
            self.img_lkpoints["last"], len( self.img_lkpoints["last"] ),
 +
            (20, 20), 3, len( self.img_lkpoints["last"] ), None,
 +
            (co.cv.CV_TERMCRIT_ITER|co.cv.CV_TERMCRIT_EPS, 20, 0.03), 0)
 +
 +
 +
===1.24.2013===
 +
* TermCriteria doesn't exist, and there's little documentation on the method on how to create the calculation for optical flow for the new version of cv.
 +
 +
'''Description of CalcOpticalFlowPyrLK()'''
 +
* Does not have an example or descriptive errors when fails.
 +
  Parameters:
 +
  prevImg – first 8-bit input image or pyramid constructed by buildOpticalFlowPyramid().
 +
  nextImg – second input image or pyramid of the same size and the same type as prevImg.
 +
  prevPts – vector of 2D points for which the flow needs to be found; point coordinates must be single-precision floating-point numbers.
 +
  nextPts – output vector of 2D points (with single-precision floating-point coordinates) containing the calculated new positions of input features in the second image; when OPTFLOW_USE_INITIAL_FLOW flag is passed, the vector must have the same size as in the input.
 +
  status – output status vector; each element of the vector is set to 1 if the flow for the corresponding features has been found, otherwise, it is set to 0.
 +
  err – output vector of errors; each element of the vector is set to an error for the corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn’t found then the error is not defined (use the status parameter to find such cases).
 +
  winSize – size of the search window at each pyramid level.
 +
  maxLevel – 0-based maximal pyramid level number; if set to 0, pyramids are not used (single level), if set to 1, two levels are used, and so on; if pyramids are passed to input then algorithm will use as many levels as pyramids have but no more than maxLevel.
 +
  criteria – parameter, specifying the termination criteria of the iterative search algorithm (after the specified maximum number of iterations criteria.maxCount or when the search window moves by less than criteria.epsilon.
 +
  flags –
 +
  operation flags:
 +
  OPTFLOW_USE_INITIAL_FLOW uses initial estimations, stored in nextPts; if the flag is not set, then prevPts is copied to nextPts and is considered the initial estimate.
 +
  OPTFLOW_LK_GET_MIN_EIGENVALS use minimum eigen values as an error measure (see minEigThreshold description); if the flag is not set, then L1 distance between patches around the original and a moved point, divided by number of pixels in a window, is used as a error measure.
 +
  minEigThreshold – the algorithm calculates the minimum eigen value of a 2x2 normal matrix of optical flow equations (this matrix is called a spatial gradient matrix in [Bouguet00]), divided by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding feature is filtered out and its flow is not processed, so it allows to remove bad points and get a performance boost
 +
 +
 +
===1.25.2013===
 +
New Error:
 +
 +
  Traceback (most recent call last):
 +
  File "mousetrap/app/main.py", line 238, in update_frame
 +
    self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 +
  File "mousetrap/ocvfw/idm/forehead.py", line 127, in get_capture
 +
    self.get_forehead()
 +
  File "mousetrap/ocvfw/idm/forehead.py", line 171, in get_forehead
 +
    self.cap.add( Point("point", "forehead", ( X, Y ), parent=self.cap, follow=True) )
 +
  File "mousetrap/ocvfw/dev/camera.py", line 333, in add
 +
    Camera.set_lkpoint(graphic)
 +
  File "mousetrap/ocvfw/_ocv.py", line 166, in set_lkpoint
 +
    (co.cv.CV_TERMCRIT_ITER | co.cv.CV_TERMCRIT_EPS, 20, 0.03))
 +
  TypeError: CvSize argument 'zero_zone' expects two integers
 +
  Traceback (most recent call last):
 +
  File "mousetrap/ocvfw/dev/camera.py", line 131, in sync
 +
    Camera.show_lkpoints()
 +
  File "mousetrap/ocvfw/_ocv.py", line 205, in show_lkpoints
 +
    (co.cv.CV_TERMCRIT_ITER|co.cv.CV_TERMCRIT_EPS, 20, 0.03), 0)
 +
  TypeError: Expected tuple for CvPoint2D32f argument 'prev_features'
 +
/usr/local/bin/mousetrap: line 139:  4335 Segmentation fault      (core dumped) /usr/bin/python -c "import mousetrap.app.main as mousetrap; mousetrap.Controller().start();" "$ARGS"
 +
 +
*The structure for CalcOpticalFlowPyrLK() is exactly from: https://code.ros.org/trac/opencv/browser/trunk/opencv/tests/python/test.py?rev=3187
 +
Which is testing the actual method, and it still shows an error.
 +
 +
=== 1.28.2013 ===
 +
 +
*I've been playing around with cv2 and trying to get a test file running and encountered a possible future error with the api.
 +
Apparently, it cannot work for all video drivers, and might potentially not work for mine. It's discussed here in this thread: http://stackoverflow.com/questions/11420748/setting-camera-parameters-in-opencv-python
 +
 +
Error:
 +
 +
  [root@amber src]# python testcv.py
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  HIGHGUI ERROR: V4L: Property Exposure(15) not supported by device
 +
  VIDIOC_QUERYMENU: Invalid argument
 +
  VIDIOC_QUERYMENU: Invalid argument                                         
 +
  VIDIOC_QUERYMENU: Invalid argument                                         
 +
  libv4l2: error setting pixformat: Device or resource busy                 
 +
  HIGHGUI ERROR: libv4l unable to ioctl S_FMT                               
 +
  libv4l2: error setting pixformat: Device or resource busy                 
 +
  libv4l1: error setting pixformat: Device or resource busy                 
 +
  HIGHGUI ERROR: libv4l unable to ioctl VIDIOCSPICT
 +
 +
  CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate production trees: Can't create any node of the requested type!
 +
It has something to do with the exposure times (so the camera will endlessly capture video)
 +
 +
* Here is a little program that will capture video from the webcam and display it (endlessly unless you CTRL+C)
 +
 +
  """
 +
  This module is used for testing the opencv2 capabilities
 +
  """
 +
  import cv2
 +
  #get webcam feed
 +
  capture = cv2.VideoCapture(0)
 +
  while True:
 +
      #combines VideoCapture.grab() and VideoCapture.retrieve()
 +
      retrieval_value, image = capture.read()
 +
      #shows captured image in a window
 +
      cv2.imshow("webcam", image)
 +
      #will stop capture with capatible webcam
 +
      if cv2.waitKey(10) == 27:
 +
          break
 +
 +
 +
=== 1.29.2013 ===
 +
 +
* found a good source for samples to change to cv2 http://fossies.org/dox/OpenCV-2.4.3/interoperability__with__OpenCV__1_8cpp.html#a3c04138a5bfe5d72780bb7e82a18e627
 +
* I believe the entire project uses a framework surrounding opencv called ctypes_opencv... http://code.google.com/p/ctypes-opencv/ (ONLY SUPPORTS V 1.0 and V 1.1 of opencv)
 +
  * this is the new version (completely remodeled) pyopencv: http://code.google.com/p/pyopencv/
 +
 +
=== 1.31.2013 ===
 +
* This proved to be helpful in looking at the cv2 error I encountered, I think it is either a iplimage not being excepted in GetSubRect() or it has wrong dimensions for the rectangle. http://stackoverflow.com/questions/11637523/is-there-a-difference-between-opencvs-cv-getsubrect-and-pils-crop
 +
 +
=== 2.4.2013 ===
 +
 +
Now I have a repeating line and nothing happens. It could be that my webcam isn't compatible. Here's the error.
 +
  DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
* I noticed that the blank window that always appears is a gtk window object and ''should'' be displaying a menu, so I started using the command line python utility to fuss around with gtk and see if I can replicate something and try to fix the code in MT.
 +
 +
=== 2.5.2013 ===
 +
 +
Receiving a new error:
 +
 +
  DEBUG: ocvfw -> cmGetHaarROIPoints: detected some matches
 +
  Traceback (most recent call last):
 +
  File "mousetrap/app/main.py", line 238, in update_frame
 +
    self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 +
  File "mousetrap/ocvfw/idm/forehead.py", line 127, in get_capture
 +
    self.get_forehead()
 +
  File "mousetrap/ocvfw/idm/forehead.py", line 174, in get_forehead
 +
    self.cap.add( Point("point", "forehead", ( X, Y ), parent=self.cap, follow=True) )
 +
  File "mousetrap/ocvfw/dev/camera.py", line 333, in add
 +
    Camera.set_lkpoint(graphic)
 +
  File "mousetrap/ocvfw/_ocv.py", line 167, in set_lkpoint
 +
    (co.cv.CV_TERMCRIT_ITER | co.cv.CV_TERMCRIT_EPS, 20, 0.03))
 +
  TypeError: CvSize argument 'zero_zone' expects two integers
 +
  DEBUG: Ocvfw -> {'current': [], 'points': [], 'last': [2618, 17866]}
 +
  Traceback (most recent call last):
 +
  File "mousetrap/ocvfw/dev/camera.py", line 131, in sync
 +
    Camera.show_lkpoints()
 +
  File "mousetrap/ocvfw/_ocv.py", line 211, in show_lkpoints
 +
    self.img_lkpoints["current"], status = optical_flow
 +
  ValueError: too many values to unpack
 +
 +
The list it is unpacking is: {'current': [], 'points': [], 'last': [3632, 19477]}
 +
 +
=== 2.6.2013 ===
 +
New error after changing optical flow calculation to cv2
 +
 +
  OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /builddir/build/BUILD/OpenCV-2.3.1/modules/imgproc/src/color.cpp, line 2834
 +
  Traceback (most recent call last):
 +
  File "mousetrap/ocvfw/dev/camera.py", line 131, in sync
 +
    Camera.show_lkpoints()
 +
  File "mousetrap/ocvfw/_ocv.py", line 204, in show_lkpoints
 +
    prevGrey = cv2.cvtColor(self.prevGrey, cv2.COLOR_BGR2GRAY)
 +
  cv2.error: /builddir/build/BUILD/OpenCV-2.3.1/modules/imgproc/src/color.cpp:2834: error: (-215) scn == 3 || scn == 4 in function cvtColor
 +
 +
=== 2.8.2013 ===
 +
* Per request: Opencv has been first released in 2006 with its 1.0 version, the latest version 2.4.3 was released in march of 2012.  On the horizon is a rumored that OpenCV 2.5 will release an aggregate "opencv_world" module which will be the whole OpenCV library in single so/dll/dylib file, but when that will happen is unknown.
 +
 +
=== 2.11.2013 ===
 +
* Updated dev help site: http://www.xcitegroup.org/foss2serve/index.php/MouseTrap_Dev_Help
 +
 +
* found a source that shows cv2 with optical flow which I'm trying to follow: https://github.com/jesolem/PCV/blob/master/pcv_book/lktrack.py
 +
 +
=== 2.14.2013 ===
 +
* Good resource for identifying the structure of numpy arrays: http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html#array-attributes
 +
New Error
 +
 +
  DEBUG: Ocvfw -> <iplimage(nChannels=3 width=640 height=480 widthStep=1920 )>
 +
  Traceback (most recent call last):
 +
  File "mousetrap/app/main.py", line 238, in update_frame
 +
    self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 +
  File "mousetrap/ocvfw/idm/forehead.py", line 127, in get_capture
 +
    self.get_forehead()
 +
  File "mousetrap/ocvfw/idm/forehead.py", line 147, in get_forehead
 +
    face    = self.cap.get_area(commons.haar_cds['Face'])
 +
  File "mousetrap/ocvfw/dev/camera.py", line 373, in get_area
 +
    return Camera.get_haar_points(haar_csd)
 +
  File "mousetrap/ocvfw/_ocv.py", line 352, in get_haar_points
 +
    cv2.resize( self.img, self.small_img, cv.CV_INTER_LINEAR )
 +
  TypeError: <unknown> is not a numpy array
 +
  Traceback (most recent call last):
 +
  File "mousetrap/ocvfw/dev/camera.py", line 127, in sync
 +
    self.__image = self.color(self.__color_set)
 +
  File "mousetrap/ocvfw/dev/camera.py", line 294, in color
 +
    co.cv.CvtColor( self.__image, tmp, self.__color_int['cv_%s2%s' % (self.__color, new_color) ])
 +
  TypeError: CvArr argument 'src' must be IplImage, CvMat or CvMatND. Use fromarray() to convert numpy arrays to CvMat or cvMatND
 +
 +
* Need to decide whether to use IplImages or numpy arrays.
 +
 +
=== 2.15.2013 ===
 +
==== Installing Fedora 18 ====
 +
 +
1) Created bootable flash drive using: sudo dd if=FEDORA.ISO of=/dev/DRIVE# bs=8M conv=fsync
 +
 +
2) Boot with flashdrive
 +
 +
- No problems
 +
 +
 +
=== 2.19.2013 ===
 +
* I decided that I'm going to put a full install method here and on the dev page.
 +
 +
==== Complete Git + Mousetrap Install ====
 +
 +
===== '''Let's get git''' =====
 +
  Open a terminal, become root
 +
  '''Run Commands:'''
 +
  -> cd /opt
 +
  -> mkdir git  (just fyi you can put your repo anywhere, this is just how I was taught)
 +
  -> yum install git-core
 +
  -> cd /opt/git
 +
  -> git clone git://github.com/amberheilman/mousetrap.git
 +
  * Now you have pulled down the git repo
 +
  -> cd mousetrap
 +
  -> git checkout fix_install (my branch)
 +
  -> git pull
 +
  '''* DO NOT MAKE CHANGES HERE'''
 +
  * We should all be working in separate branches!
 +
 +
===== '''Make a branch:''' =====
 +
  -> git branch INSERT_BRANCH_NAME      * this clones my branch and creates a new one
 +
  -> git checkout INSERT_BRANCH_NAME    * this opens up your branch that you just created
 +
  -> git branch                        * now you can see the branch your in with a *, and all others under this git repo
 +
 +
===== '''Mousetrap Install method''' =====
 +
  '''Install Dependencies:'''
 +
  -> yum install gnome-common
 +
  -> yum install glib2-devel
 +
  -> yum install intltool
 +
  -> yum install python-devel
 +
  -> yum install opencv-python
 +
  -> yum install python-xlib
 +
  '''Run Commands:'''
 +
  -> cd /opt/git/mousetrap/src          * THIS WILL NOT WORK OUTSIDE THIS DIR!
 +
  -> cd ..
 +
  -> ./autogen.sh
 +
  -> make
 +
  -> make install
 +
  -> mousetrap                          * You may have errors but they should be similar to my own (towards the end)
 +
 +
===== '''Make your first commit''' =====
 +
  -> git status                        * Shows all of the modified files
 +
  -> git add *                          * This is to add ALL files to commit list (MAKE SURE YOU WANT THEM ALL FIRST!)
 +
  -> git commit                        * Add a useful title to '''first line''' of your commit.
 +
                                          This is in vim so 'i' to insert ':x' to save and quit.
 +
  -> git push origin INSERT_BRANCH_NAME * This must be the branch you created in the git install.
 +
                                          This will ask for your git credentials, so have them ready.
 +
|}
 +
 +
 +
<div class="toccolours mw-collapsible" style="width:800px">
 +
'''Status CURRENT'''
 +
----
 +
=== 8.4.2013 ===
 +
I am running into the segfault issue that Logan was talking about.
 +
 +
 +
 +
</div>
 +
 +
==Logan Status==
 +
To make it easier to edit and follow, I have moved my updates to a new page: [[Logan Status Updates]]
 +
 +
==John Status==
 +
===12/29/12===
 +
 +
* Noted that mousetrap and gnome-mousetrap are in the Ubuntu repository. Ignoring this and following instructions provided by the MouseTrap GNOME Live! project page…
 +
 +
* Installation went as expected. Ran into every issue in the 'Troubleshooting' table, but that seems to be expected behavior.
 +
 +
* Running MouseTrap with command 'mousetrap'. Expected errors due to lack of webcam.  Otherwise seems to run without issue (preferences window pops up when button clicked, and so forth).
 +
 +
* Quits without issue.
 +
 +
Thoughts on Install Process:
 +
 +
* Noted that it might be nice if they add the commands for the RPM package  manager to the instructions.
 +
 +
* "Troubleshooting" should be a link to the Troubleshooting section for user-friendliness.
 +
 +
* 'Dependency hell' is tedious. Due to the fact that MouseTrap is in the Ubuntu  repositories suggests it might be in others as well. It might be useful to include this fact in the  install instructions.
 +
 +
* Else it might be useful for the autogen.sh shell file to automatically detect if a package is  installed (it already does this) and installs them if they are not. This will run into an issue with  different package management systems. A different shell file for the popular ones (APT and RPM)?
 +
 +
* A GUI installer would be the most user-friendly, but that's not the Linux MO.
 +
===1/13/13===
 +
* Webcam received and set up. Seems to be recognized OOTB on Ubuntu -- the light goes on when in use, etc.
 +
 +
* When running Mousetrap, it shows a blank window (most of the time) or a frozen video frame (only seen this once). In the terminal, it repeatedly displays errors similar to this;
 +
 +
Corrupt JPEG data: 1 extraneous bytes before marker 0xd9
 +
 +
* When running again with webcam unplugged, it runs fine.
 +
 +
* A quick Google got me this, https://bugs.launchpad.net/ubuntu/+source/mousetrap/+bug/685777 which is similar but not exactly (in my case the program gets stuck instantly).
 +
===1/25/13===
 +
Replaced Ubuntu with Fedora 18 on system. Webcam works out of the box. Everything works nicely. Except for the new UI for Anaconda, but I digress. Had issues installing Mousetrap. Full details below...
 +
 +
====Installing Fedora:====
 +
 +
I downloaded the ISO image for the Fedora 18 Network Install CD from here http://fedoraproject.org/en/get-fedora-options#formats. This is good if you have fast internet access. This is ideal since a) it's a small(er) download, and b) dd takes a while (see below).
 +
 +
Instead of a CD/DVD, I decided to use a USB stick. I used the Fedora-suggested LiveUSB tool, but it produced a USB stick that either a) is not recognized as bootable, or b) freezes at or after the "Secure boot not enabled" screen. So I used dd instead (a nifty tool, which should already be installed if you're using a UNIX-based OS, that copies a disk image to a destination byte-for-byte). To put the .iso image onto my USB stick, I used the command,
 +
 +
# dd if=./Fedora-18-x86_64-netinst.iso of=/etc/rdisk1
 +
 +
I had to be root to do this (hence the # above). Note that I also put "r" before the device name (in the above example, I used rdisk1 instead of disk1). This enables direct access, which speeds things up considerably. I used
 +
 +
$ fdisk -l
 +
 +
to find out the location of the USB drive.
 +
 +
Once I executed the dd command, it sat there seemingly doing nothing. dd can take a while (hence the reason I didn't use the Live DVD ISO!).
 +
 +
After it was done, booted from the USB drive, followed the (horrid) Anaconda installation process (beware of the terrifying partitioning part!).
 +
 +
After that's done, booted up and installed the b43 driver for my wireless card using the guide here, http://linuxwireless.org/en/users/Drivers/b43#Fedora. Everything works great, including the webcam.
 +
 +
====Installing Mousetrap:====
 +
 +
I attempted to install all the dependencies listed on the Mousetrap GNOME Live! site using the usual yum install <package>. However pygtk, python-pyspi and libglib2.0 are not in the repos.
 
[[Category:Gnome_MouseTrap]]
 
[[Category:Gnome_MouseTrap]]
 +
 +
  ''' Install method'''
 +
  Install Dependencies:
 +
  * gnome-common
 +
  * glib2-devel
 +
  * intltool
 +
  * python-devel
 +
  * opencv-python
 +
  * python-xlib
 +
  Run Commands:
 +
  -> run git branch fix_install
 +
  -> run ./autogen.sh
 +
  -> make
 +
  -> make install
 +
  -> run mousetrap from /src
 +
  (let me know if this works for you --Amber)
 +
===2/8/13===
 +
Installed Mousetrap successfully via Amber's instructions above. Ran into an error;
 +
  ImportError: could not import gobject (error was: ImportError('When using gi.repository you must not import static modules
 +
  like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject".',))
 +
===2/16/13===
 +
Started on learning the Python language using "Learning Python, 4th Edition."
 +
 +
  I don't think that you are in the correct branch. You downloaded a clone via git, right?
 +
  I put up an entire install method, see if you missed something.
 +
 +
===4/21/13===
 +
NOTES TO SELF:
 +
 +
Worked on getting OpenCV webcam view into GTK+ UI.
 +
 +
Wrote a very simple program using straight OpenCV API. Works fine.
 +
 +
Wrote a GTK+ based program that takes a photo via the webcam and saves it as a file. Also works fine.
 +
 +
With those experiences in my belt, I tried integrating the two, to little success.
 +
 +
Yes, I've tried using the photo program I wrote above to brute-force a display of a video via a loop -- but knew before I begun that it's a horribly bad (and potentially dangerous!) idea.
 +
 +
Googling keeps leading me to GdkPixBuf (previously gtk.gdk.PixBuf in PyGTK). Requires iplimage (used by OpenCV) to be converted into PIL (Python Image Language) before it can be converted into PixBuf via new_from_data. OpenCV used to have adaptors that can do this, but it was, for some reason, deprecated with no equivalent replacement.
 +
 +
There's some nonsense about NumPy and/or Matlibplot as well.
 +
 +
But all of this is moot for the time being due to finding out that the new_from_data API seems to be broken for Python -- http://stackoverflow.com/questions/10284465/gdkpixbuf-pixbufdestroynotify-notimplementederror-python-gtk3
 +
 +
One possible alternative is to use new_from_array, creating an array from the image via Array (or NumPy array, not sure). But I haven't looked too deeply on how to a) convert an iplimage to a PIL then/or to an array, and b) how to use new_from_array.
 +
 +
Another possible alternative -- due to OpenCV using a Qt backend -- is to use Plug() and Socket() in GTK+ to embed the OpenCV window into a GTK+ window. Haven't figured out how to do this due to OpenCV's limited UI API. Maybe a Qt API can interact with windows created by OpenCV?
 +
 +
Another alternative; I checked out Cheese (a open source Photobooth rip off that comes preinstalled with Fedora) -- turns out it uses Gstreamer to capture images from the webcam. As Gstreamer works great with GTK+, perhaps one solution would be to use Gstreamer for the UI, and OpenCV for the background heavy-lifting?
 +
 +
===4/30/13===
 +
After the discussion on Friday of how MouseTrap was supposed to work, and whether it even worked "in the wild" at all, I decided to compile it and see what I can find out with all that I've learned in the past few months in the hopes of gathering some useful information for future use.
 +
 +
We know that MouseTrap compiles in Ubuntu 10.4, so I installed Ubuntu 10.4 on a virtual machine, and followed the instructions on the MouseTrap GNOME Live! webpage. Additionally, I compiled Mousetrap with the --enable-doxygen and --enable-docbook flags (from the bottom of the installation instructions page) to get the doxygen-generated developer documentation and user documentation, respectively. Those are not obtainable without compiling MouseTrap, and we all know it does not compile in Fedora 18.
 +
 +
The user documentation (docbook) and doxygen-generated documentation are on my GitHub repo; ([http://github.com/riveraj/MouseTrap-Stuff])
 +
 +
Additionally, I ran Mousetrap multiple times, and found three "scenarios", each occurring at random. I have documented the "scenarios" below.
 +
 +
 +
 +
The first scenario is where Mousetrap runs, and displays a frozen captured frame from the webcam, and nothing else. The output in the terminal is as follows:
 +
 +
john@john-desktop:~/mousetrap$ mousetrap
 +
Xlib.protocol.request.QueryExtension
 +
DEBUG: mousetrap.ocvfw.idm -> Starting Forehead idm
 +
INFO: mousetrap.ocvfw.idm -> Forhead Algorithm loaded
 +
DEBUG: mousetrap.ocvfw.idm -> Setting Capture
 +
DEBUG: Commons -> New Singleton Add (mousetrap.ocvfw.dev.camera.Camera)
 +
DEBUG: ocvfw -> cmStartCamera: Camera Started
 +
DEBUG: Camera -> Loaded backend OcvfwPython
 +
DEBUG: OcvfwBase -> Changed lk_swap value to True
 +
INFO: mousetrap - Idm loaded and started
 +
DEBUG: ui.main - Interface Built
 +
DEBUG: ui.main - Addons loaded
 +
INFO: mousetrap - MouseTrap's Interface Built and Loaded
 +
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
Traceback (most recent call last):
 +
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/dev/camera.py", line 116, in sync
 +
    Camera.query_image()
 +
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/_ocv.py", line 140, in query_image
 +
    co.cv.cvCvtColor(self.img, self.grey, co.cv.CV_BGR2GRAY)
 +
  File "/usr/lib/pymodules/python2.6/opencv/cv.py", line 6759, in cvCvtColor
 +
    return _cv.cvCvtColor(*args)
 +
RuntimeError:  openCV Error:
 +
        Status=Null pointer
 +
        function name=cvGetMat
 +
        error message=NULL array pointer is passed
 +
        file_name=cxcore/cxarray.cpp
 +
        line=2370
 +
Traceback (most recent call last):
 +
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/app/main.py", line 238, in update_frame
 +
    self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 +
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/idm/forehead.py", line 128, in get_capture
 +
    self.get_forehead()
 +
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/idm/forehead.py", line 148, in get_forehead
 +
    face    = self.cap.get_area(commons.haar_cds['Face'])
 +
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/dev/camera.py", line 373, in get_area
 +
    return Camera.get_haar_points(haar_csd)
 +
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/_ocv.py", line 340, in get_haar_points
 +
    co.cv.cvResize( self.img, self.small_img, co.cv.CV_INTER_LINEAR )
 +
  File "/usr/lib/pymodules/python2.6/opencv/cv.py", line 6763, in cvResize
 +
    return _cv.cvResize(*args)
 +
RuntimeError:  openCV Error:
 +
        Status=Null pointer
 +
        function name=cvGetMat
 +
        error message=NULL array pointer is passed
 +
        file_name=cxcore/cxarray.cpp
 +
        line=2370
 +
 +
Screenshot: [[File:screenshot1.png]]
 +
 +
 +
 +
The second scenario is where Mousetrap runs, with no image displayed. The output in the terminal is as follows:
 +
 +
john@john-desktop:~$ mousetrap
 +
Xlib.protocol.request.QueryExtension
 +
DEBUG: mousetrap.ocvfw.idm -> Starting Forehead idm
 +
INFO: mousetrap.ocvfw.idm -> Forhead Algorithm loaded
 +
DEBUG: mousetrap.ocvfw.idm -> Setting Capture
 +
DEBUG: Commons -> New Singleton Add (mousetrap.ocvfw.dev.camera.Camera)
 +
DEBUG: ocvfw -> cmStartCamera: Camera Started
 +
DEBUG: Camera -> Loaded backend OcvfwPython
 +
DEBUG: OcvfwBase -> Changed lk_swap value to True
 +
INFO: mousetrap - Idm loaded and started
 +
DEBUG: ui.main - Interface Built
 +
DEBUG: ui.main - Addons loaded
 +
INFO: mousetrap - MouseTrap's Interface Built and Loaded
 +
Corrupt JPEG data: 5113 extraneous bytes before marker 0xd2
 +
Traceback (most recent call last):
 +
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/dev/camera.py", line 116, in sync
 +
    Camera.query_image()
 +
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/_ocv.py", line 129, in query_image
 +
    self.imgSize        = co.cv.cvGetSize (frame)
 +
  File "/usr/lib/pymodules/python2.6/opencv/cv.py", line 4350, in cvGetSize
 +
    return _cv.cvGetSize(*args)
 +
RuntimeError:  openCV Error:
 +
        Status=Bad argument
 +
        function name=cvGetSize
 +
        error message=Array should be CvMat or IplImage
 +
        file_name=cxcore/cxarray.cpp
 +
        line=1227
 +
Traceback (most recent call last):
 +
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/app/main.py", line 238, in update_frame
 +
    self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 +
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/idm/forehead.py", line 128, in get_capture
 +
    self.get_forehead()
 +
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/idm/forehead.py", line 148, in get_forehead
 +
    face    = self.cap.get_area(commons.haar_cds['Face'])
 +
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/dev/camera.py", line 373, in get_area
 +
    return Camera.get_haar_points(haar_csd)
 +
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/_ocv.py", line 335, in get_haar_points
 +
    cascade = co.cv.cvLoadHaarClassifierCascade( haarCascade, self.imgSize )
 +
AttributeError: Camera instance has no attribute 'imgSize'
 +
 +
Screenshot: [[File:screenshot2.png]]
 +
 +
 +
 +
The third scenario, which is rare compared to the above two, is rather interesting. Mousetrap begins with a completely blank window (no widgets, only the title bar) and hijacks the mouse. Most of the time, the mouse is stuck at the lower left corner, but occasionally it would flicker around the screen (no smooth motion, it simply appears and disappears at seemingly random points). This is not in response to the webcam feed as far as I could tell. The behavior does not change even when the webcam is covered. There is also no way to exit the program; I had to do a killall.
 +
 +
The terminal output is:
 +
 +
john@john-desktop:~$ mousetrap
 +
Xlib.protocol.request.QueryExtension
 +
DEBUG: mousetrap.ocvfw.idm -> Starting Forehead idm
 +
INFO: mousetrap.ocvfw.idm -> Forhead Algorithm loaded
 +
DEBUG: mousetrap.ocvfw.idm -> Setting Capture
 +
DEBUG: Commons -> New Singleton Add (mousetrap.ocvfw.dev.camera.Camera)
 +
DEBUG: ocvfw -> cmStartCamera: Camera Started
 +
DEBUG: Camera -> Loaded backend OcvfwPython
 +
DEBUG: OcvfwBase -> Changed lk_swap value to True
 +
INFO: mousetrap - Idm loaded and started
 +
DEBUG: ui.main - Interface Built
 +
DEBUG: ui.main - Addons loaded
 +
INFO: mousetrap - MouseTrap's Interface Built and Loaded
 +
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
Corrupt JPEG data: 1372 extraneous bytes before marker 0xd2
 +
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 +
 +
... and so on infinitely.
 +
 +
==Nicole's Status==
 +
 +
===1.25.2013===
 +
Fedora 18 was successfully installed. Instructions are now on the "Getting Started" page.
 +
 +
===2.5.2013===
 +
MouseTrap was fully installed. Instructions are now on the "Getting Started" page. I encountered the same first error:
 +
  ImportError: could not import gobject (error was: ImportError('When using gi.repository you must not import static modules
 +
  like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject".',))
 +
* Amber, have you put up your latest fork onto your github yet?
 +
 +
  Yes, do you have git installed? (Not really sure how much git you know, so I'll just put up instructions for all.)
 +
  If not, open a terminal, become root
 +
  cd to /opt
 +
  mkdir git  (just fyi you can put your repo anywhere, this is just how I was taught)
 +
  run yum install git-core
 +
  cd into git folder
 +
  run git clone git://github.com/amberheilman/mousetrap.git
 +
  now you have pulled down my code.
 +
 +
  To start using the code I'm currently working on:
 +
  run:
 +
  git checkout fix_install (my branch)
 +
  git pull
 +
  * DO NOT MAKE CHANGES HERE (we should all be working in separate branches)
 +
  git branch INSERT_BRANCH_NAME (this clones my branch and creates a new one)
 +
  git checkout INSERT_BRANCH_NAME (this opens up your branch that you just created)
 +
  git branch (now you can see the branch your in with a *, and all others under this git repo)
 +
  * We should also be making commits on a frequent basis with commit titles that show exactly what was changed
 +
  * Hope this helps
 +
 +
    @Amber from Stoney: It sounds like you're suggesting that Nicole share your repository.
 +
    If so, she'll need to create a GitHub account, and you'll need to add her as a contributor on your fork.
 +
 +
    (cont.) Alternatively, when Nicole has something to contribute, she could make a patch and send it to you.
 +
 +
    (cont.) Another alternative, Nicole could fork your fork using GitHub (she'll need to create an account).
 +
    When she has something to contribute, she can make a pull request to your fork, you can review the changes
 +
    and accept/reject. Directions/tutorial for this approach are here: https://help.github.com/articles/fork-a-repo .
 +
 +
===2.7.2013===
 +
Made my own github account and forked off of amber's at: https://github.com/WNEmousetrap/mousetrap
 +
 +
Ran mousetrap and now getting error:
 +
Traceback (most recent call last):
 +
  File "<string>", line 1, in <module>
 +
  File "mousetrap/app/main.py", line 42, in <module>
 +
    import environment as env
 +
ImportError: No module named environment
 +
 +
  NOTE: Remember even if you download my code you still need to run the install
 +
  so cd into the git repo /mousetrap and do a ./autogen.sh which checks to make sure
 +
  your dependencies are there (see what I wrote to john). Then you will have to run "make"
 +
  after that is done run "sudo make install"
 +
  Then you should be able to cd to /mousetrap/src and type "mousetrap" to run the program. Otherwise
 +
  it will give you errors like above because files were not created by the make command.
 +
 +
  *Side note:, if you would like to be added to my fork I can do that easily, just send me your username.
 +
  Plus I think it will be easier for us all to communicate if we're working off of the same repo. (-Amber)
 +
 +
===2.12.2013===
 +
Started to document OpenCV using the information at http://docs.opencv.org/ . I'm starting right with the Introduction and reading through. Trying to get definitions and history from here as much as I can.
 +
 +
===2.13.2013===
 +
Continuing documentation. Found a few sources towards the community. Getting into reading about API Concepts currently.
 +
 +
===2.15.2013===
 +
Started looking at OpenCV 2 documentation. Organized the Dev Help page. Starting to focus on CV 2 documentation for now, most of the general information seems to be the same anyways.
 +
 +
===2.19.2013===
 +
Found the meeting notes from the OpenCV community; starting to read through them with the first meeting notes starting in 2008 (http://code.opencv.org/projects/opencv/wiki/Meeting_notes)
 +
* stopped at 2009-02-03 for now
 +
 +
===2.20.2013===
 +
Continued with meeting notes -
 +
 +
===2.21.2013===
 +
Meeting notes - stopped at 2009-06-02 for now.
 +
 +
===3.28.2013===
 +
Started to look into what the Makefiles in mousetrap really do; looking through the pdf slides for GNU "autotools" from http://www.lrde.epita.fr/~adl/autotools.html
 +
 +
===3.30.2013===
 +
Continued reading through slideshow.
 +
 +
===4.2.2013===
 +
Finished slideshow in preparation for the sprint on Friday. Started researching on Gnome's site to see how they talk about autotools for their projects.
 +
 +
===4.4.2013===
 +
Found a few things on the Gnome site:
 +
#A basic Gnome project tutorial: https://developer.gnome.org/anjuta-build-tutorial/stable/index-info.html.en '''REALLY GOOD!!'''
 +
#A suggestion for a "modernized" autotools: https://live.gnome.org/GnomeGoals/ModernAutotools
 +
#The site does bump me back to the original pdf slideshow that I read through. This is a good sign!!
 +
The basic tutorial is very good to read through. It is a little smaller than the pdf so it would take much less time to get through,
 +
but it  still has great information. I still recommend reading through at least parts of the pdf if you have time, but the tutorial is an
 +
EXCELLENT starting point!
 +
 +
===4.5.2013===
 +
Mousetrap Sprint all day!!
 +
Worked on understanding Makefiles.am's and created a Directory Tree for whole mousetrap folder (not just src) and accompanying Makefile.am's in those directories if they existed.
 +
 +
[[File:Makefile_am_Tree.png|1200px|thumb|left|Makefile Tree]]
 +
 +
===4.11.2013===
 +
Starting to work through unit testing the "app" and GUI section of the project. Reading up on how gtk works and how the code should look. Will then look at the mousetrap code and add in the functionality that they have to see where the program "breaks."
 +
* When only trying to write a file to import gtk I got the error:
 +
Traceback (most recent call last):
 +
  File "gtk_test.py", line 1, in <module>
 +
    import gtk
 +
  File "/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py", line 40, in <module>
 +
    from gtk import _gtk
 +
ImportError: /lib64/libEGL.so.1: undefined symbol: wl_display_dispatch_queue_pending
 +
 +
 +
* I am now looking into how gtk (especially pygtk) is suppose to work. I am using the tutorial: http://pygtk.org/pygtk2tutorial/
 +
 +
===4.12.2013===
 +
Still reading through the tutorial about gtk. Going to try to make a small test program for a sample gtk application. Also looking into fixing the gtk import issue.
 +
 +
'''Fixed the gtk issue!'''
 +
It was a simple version issue. All I needed to do was run:
 +
sudo yum update libwayland-server
 +
sudo yum update libwayland-client
 +
The version I was on was 1.0.0. A new symbol was added in 1.0.2. The most recent version out is 1.0.5.
 +
 +
I managed to create a small working gtk application window!!! Below is the code you can put into a test file (such as mine "gtk_sample.py) and run with "python2 gtk_sample.py":
 +
 +
# example gtk program
 +
 +
import pygtk
 +
pygtk.require('2.0')
 +
import gtk
 +
 +
class gtk_sample:
 +
  def callback(self, widget, data):
 +
    print("Hello again - %s was pressed" % data)
 +
 +
  def delete_event(self, widget, event, data=None):
 +
    gtk.main_quit()
 +
    return False
 +
 +
  def __init__(self):
 +
    self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
 +
    self.window.set_title("gtk example")
 +
    self.window.connect("delete_event", self.delete_event)
 +
    self.window.set_border_width(50)
 +
 +
    self.box1 = gtk.HBox(False, 0)
 +
    self.window.add(self.box1)
 +
 +
    self.button1 = gtk.Button("Yes")
 +
    self.button1.connect("clicked", self.callback, "yes")
 +
    self.box1.pack_start(self.button1, True, True, 0)
 +
    self.button1.show()
 +
 +
    self.button2 = gtk.Button("No")
 +
    self.button2.connect("clicked", self.delete_event, "no")
 +
    self.box1.pack_start(self.button2, True, True, 0)
 +
    self.button2.show()
 +
 +
    self.box1.show()
 +
 +
    self.window.show()
 +
 +
def main():
 +
  gtk.main()
 +
 +
if __name__ == '__main__':
 +
  sample = gtk_sample()
 +
  main()
 +
 +
 +
===5.15.2013===
 +
I returned to work today since it is the first week of summer break for me. I will normally be in the lab and working on MouseTrap from 1-5pm on Wednesdays and Fridays.
 +
 +
Today I fixed the Ubuntu machine (as per Amber's and Logan's suggestions from a week ago, THANKS AGAIN!) and was able to get past the weird gi.repository issue, though I have an inkling on how to fix it on the Fedora too, I just haven't explored that yet. I was able to debug the code I rewrote from the original source code for the GUI and it doesn't break... but it also doesn't show me an interface.
 +
 +
I moved on to completely writing my own version of the ui.main file and have an interface that shows up with 3 buttons! I am now looking through the ui.settings_gui file and trying to debug that show it shows up when I run my file.
 +
 +
===6.12.2013===
 +
Sorry I haven't updated in a while, I've been head over heels busy.... Anyways, I have been working on trying to get the GUI interface working with GTK 3 based code. I started to re-code the top main.py in the app/ directory and will be continuing to debug it on Friday. Today I am working on looking through other files in the app/ directory and rewriting them to be GTK 3 friendly.

Latest revision as of 12:44, 15 October 2018

Contents

DEVELOPMENT HELP PAGE: http://xcitegroup.org/foss2serve/index.php/MouseTrap_Dev_Help (includes opencv status)

INSTALLED PACKAGES

Please state the versions and OS you are currently working with so that versioning errors can be ruled out.

Team Member Name Installed Packages Team Member Name Installed Packages
Amber (8/5/2013)
Package Name Version
Fedora 19
Gnome 3.8.2
Python 2.7.5
gtk3 3.8.2
pygtk2 2.24.0
opencv 2.4.5
python-xlib 0.15
at-spi-python 1.32.0
gnome-common 3.7.4
glib2-devel (libglib2.0-dev) 2.36.3
intltool 0.50.2


Logan
Package Name Version
Fedora 17
Gnome 3.4.2
Python 2.7.3
gtk2 2.24.13
pygtk2 2.24.0
opencv 2.3.1
python-xlib 0.15
at-spi-python (python-pyspi) 1.32.0
gnome-common 3.4.0.1
glib2-devel (libglib2.0-dev) 2.32.4
doxygen 1.8.1
intltool 0.50
John
Package Name Version
Fedora 18
Gnome 2.30.2
Python 2.6.5-0ubuntu1
gtk2 2.20.1-0ubuntu2.1
pygtk2 ???
opencv 2.0.0-3ubuntu2
python-xlib 0.14+20091101-1
at-spi-python (python-pyspi) not installed
gnome-common 2.28.0-1
glib2-devel (libglib2.0-dev) 2.32.4
doxygen 1.8.1
intltool 0.41.0-0ubuntu1


Nicole
Package Name Version
Fedora 17
Gnome 3.4.2
Python 2.7.3
gtk2 (version 3 breaks api) 2.4.13
pygtk2 2.24.0
opencv (cv) 2.3.1
python-xlib 0.15
at-spi-python (python-pyspi) 1.32.0
gnome-common 3.4.0.1
glib2-devel (libglib2.0-dev) 2.32.4
intltool 0.50.2


STATUS

Please enter the status of the ongoing project below

Stoney Status

Stoney is documenting his efforts on his blog: http://stoney-jackson.blogspot.com/

Amber Status

Status 2012

12.10.2012

Full install of mousetrap complete. Config file was manipulated to include failed dependency on 'python-opencv' which has been updated and the package is now referred to as 'cv'. Other dependencies are outdated or the names have been changed as well (xlib-python, etc). New errors with 'gobject' have been identified. Here is the recorded error when running mousetrap:


 ImportError: could not import gobject
 (error was: ImportError('When using gi.repository you must not import static modules like "gobject".
 Please change all occurrences of "import gobject" to "from gi.repository import GObject".',))
 ^C[amber@localhost src]$ Traceback (most recent call last)
 File "<string>", line 1, in <module>
 File "mousetrap/app/main.py", line 50, in <module>
   from lib import httpd, dbusd, settings
 File "mousetrap/app/lib/httpd.py", line 31, in <module>
   import mouse
 File "mousetrap/app/lib/mouse.py", line 30, in <module>
   import pyatspi
 File "/usr/lib/python2.7/site-packages/pyatspi/__init__.py", line 17, in <module>
   from gi.repository import Atspi
 File "/usr/lib/python2.7/site-packages/gi/__init__.py", line 23, in <module>
   from ._gi import _API, Repository

Fix: changed import gobject to from gi.repository import GObject like suggested and changed all instances of gobject to GObject

 Changed these files:
 mousetrap/app/main.py
 mousetrap/app/addons/recalc.py
 mousetrap/app/addons/cpu.py
 mousetrap/app/ui/widgets.py
 mousetrap/ocvfw/dev/camera.py


12.11.2012

New error is present:

 /usr/lib/python2.7/site-packages/gobject/constants.py:24:
 Warning: g_boxed_type_register_static: assertion `g_type_from_name(name) == 0' failed
 import gobject._gobject
 Traceback (most recent call last):
 File "<string>", line 1, in <module>
 File "mousetrap/app/main.py", line 91, in start
   idm = pocv.get_idm(self.cfg.get("main", "algorithm"))
 File "mousetrap/ocvfw/pocv.py", line 43, in get_idm
   [])
 File "mousetrap/ocvfw/idm/forehead.py", line 32, in <module>
   from mousetrap.ocvfw.dev.camera import Capture, Point
 File "mousetrap/ocvfw/dev/camera.py", line 34, in <module>
   from mousetrap.ocvfw import _ocv as ocv
 File "mousetrap/ocvfw/_ocv.py", line 282, in <module>
   class OcvfwPython(OcvfwBase):
 File "mousetrap/ocvfw/_ocv.py", line 293, in OcvfwPython
   [])
 ImportError: No module named opencv.cv
 /usr/lib/python2.7/site-packages/gobject/constants.py:24:
 Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
 import gobject._gobject
 ^CTraceback (most recent call last):
 File "<string>", line 1, in <module>
 File "mousetrap/app/main.py", line 91, in start
   idm = pocv.get_idm(self.cfg.get("main", "algorithm"))
 File "mousetrap/ocvfw/pocv.py", line 43, in get_idm
   [])
 File "mousetrap/ocvfw/idm/forehead.py", line 32, in <module>
   from mousetrap.ocvfw.dev.camera import Capture, Point
 File "mousetrap/ocvfw/dev/camera.py", line 34, in <module>
   from mousetrap.ocvfw import _ocv as ocv
 File "mousetrap/ocvfw/_ocv.py", line 282, in <module>
   class OcvfwPython(OcvfwBase):
 File "mousetrap/ocvfw/_ocv.py", line 293, in OcvfwPython
   [])

Will attempt to remove instances of broken dependency opencv to the newer cv

  • Fix: replace the "opencv.cv" in _ocv.py on line 290 with "cv"

12.17.2012

Bug for pygobject is here: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=649861

  • The fix is to upgrade to version 3 of gtk?
  • Changed line in configure.in file to AM_CHECK_PYMOD(cv,,,[AC_MSG_ERROR(Could not find python module cv)]) to fix opencv problem when creating make files
  • Highgui no longer exists in the new API for cv (once known as opencv) and it should just be called as cv.whatever.
  • cvCreateCameraCapture() no longer exists, replaced with cv.CaptureFromCAM().

New Error

 /usr/lib/python2.7/site-packages/gobject/constants.py:24:
 Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
 import gobject._gobject
 DEBUG: mousetrap.ocvfw.idm -> Starting Forehead idm
 INFO: mousetrap.ocvfw.idm -> Forhead Algorithm loaded
 DEBUG: mousetrap.ocvfw.idm -> Setting Capture
 DEBUG: Commons -> New Singleton Add (mousetrap.ocvfw.dev.camera.Camera)
 VIDIOC_QUERYMENU: Invalid argument
 VIDIOC_QUERYMENU: Invalid argument
 VIDIOC_QUERYMENU: Invalid argument
 DEBUG: ocvfw -> cmStartCamera: Camera Started
 DEBUG: Camera -> Loaded backend OcvfwPython
 DEBUG: OcvfwBase -> Changed lk_swap value to True
 INFO: mousetrap - Idm loaded and started
 Traceback (most recent call last):
 File "<string>", line 1, in <module>
 File "mousetrap/app/main.py", line 101, in start
   self.itf = MainGui(self)
 File "mousetrap/app/ui/main.py", line 54, in __init__
   self.script = self.ctr.script()
 File "mousetrap/app/main.py", line 229, in script
   return get_script_class(self.cfg.get("scripts", "name"))()
 File "mousetrap/app/ui/scripts/__init__.py", line 45, in get_script_class
   script = __import__(script_name, globals(), locals())
 File "mousetrap/app/ui/scripts/joystick.py", line 36, in <module>
   from ..widgets import Mapper
 File "mousetrap/app/ui/widgets.py", line 236, in <module>
   GObject.type_register(Mapper)
 TypeError: argument must be a GObject subclass

Will look into gtk and GObject for error


12.19.2012

  • In this particular file: widgets.py, we actually want to import gobject directly and type_register the Mapper using gobject. After doing this, I have the Window pop up and now a new error has come up.

New Error

 /usr/lib/python2.7/site-
 packages/gobject/constants.py:24: Warning: 
 g_boxed_type_register_static: assertion 
 `g_type_from_name (name) == 0' failed
 import gobject._gobject
 DEBUG: mousetrap.ocvfw.idm -> Starting Forehead idm
 INFO: mousetrap.ocvfw.idm -> Forhead Algorithm loaded
 DEBUG: mousetrap.ocvfw.idm -> Setting Capture
 DEBUG: Commons -> New Singleton Add   
 (mousetrap.ocvfw.dev.camera.Camera)
 VIDIOC_QUERYMENU: Invalid argument
 VIDIOC_QUERYMENU: Invalid argument
 VIDIOC_QUERYMENU: Invalid argument
 DEBUG: ocvfw -> cmStartCamera: Camera Started
 DEBUG: Camera -> Loaded backend OcvfwPython
 DEBUG: OcvfwBase -> Changed lk_swap value to True
 INFO: mousetrap - Idm loaded and started
 DEBUG: ui.main - Interface Built
 DEBUG: ui.main - Addons loaded
 INFO: mousetrap - MouseTrap's Interface Built and  
 Loaded
 Traceback (most recent call last):
 File "mousetrap/ocvfw/dev/camera.py", line 116, in sync
   Camera.query_image()
 File "mousetrap/ocvfw/_ocv.py", line 125, in query_image
   frame = co.hg.cvQueryFrame( self.capture )
 AttributeError: 'module' object has no attribute 'cvQueryFrame'
 Traceback (most recent call last):
 File "mousetrap/app/main.py", line 238, in update_frame
   self.itf.update_frame(self.idm.get_capture(),   self.idm.get_pointer())
 File "mousetrap/ocvfw/idm/forehead.py", line 128,   in get_capture
   self.get_forehead()
 File "mousetrap/ocvfw/idm/forehead.py", line 148, in get_forehead
   face     =   self.cap.get_area(commons.haar_cds['Face'])
 File "mousetrap/ocvfw/dev/camera.py", line 373, in get_area
   return Camera.get_haar_points(haar_csd)
 File "mousetrap/ocvfw/_ocv.py", line 335, in get_haar_points
   cascade = co.cv.cvLoadHaarClassifierCascade( haarCascade, self.imgSize )
 AttributeError: 'module' object has no attribute 'cvLoadHaarClassifierCascade'
 /usr/local/bin/mousetrap: line 139:  6073   Segmentation fault      (core dumped)   /usr/bin/python -c "import mousetrap.app.main as   mousetrap; mousetrap.Controller().start();" "$ARGS"
  • hg no longer exists. _ocv.py should be looked over for inconsistencies with new api
  • Changed line 125 in _ocv.py to frame = co.hg.QueryFrame( self.capture )
 _ocv needs to change many dependencies for the new api
  • Changed import in widgets.py to 'import gobject' and changed to 'gobject.register_type(Mapper)'

I have no other error besides this:

 /usr/lib/python2.7/site-  packages/gobject/constants.py:24: Warning:   g_boxed_type_register_static: assertion   `g_type_from_name (name) == 0' failed
 import gobject._gobject

and this:

 (mousetrap:19550): Gtk-WARNING **: Unable to locate theme engine in module_path: "clearlooks",


I believe this is explained in this reported bug: https://bugs.launchpad.net/bzr-gtk/+bug/923824

  • There is a whole big issue with dependencies surrounding pygobject, pygtk, and gtk that are causing errors.


12.20.2012

Looked into error with pygobject, gtk and pygtk and found that the import gi must be the first import in main.py

Status Jan-Aug 2013

1.7.2013

New error

 /usr/lib/python2.7/site-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
 import gobject._gobject
 DEBUG: mousetrap.ocvfw.idm -> Starting Forehead idm
 INFO: mousetrap.ocvfw.idm -> Forhead Algorithm loaded
 DEBUG: mousetrap.ocvfw.idm -> Setting Capture
 DEBUG: Commons -> New Singleton Add (mousetrap.ocvfw.dev.camera.Camera)
 CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate production trees: Can't create any   node of the requested type!
 DEBUG: ocvfw -> cmStartCamera: Camera Started
 DEBUG: Camera -> Loaded backend OcvfwPython
 DEBUG: OcvfwBase -> Changed lk_swap value to True
 INFO: mousetrap - Idm loaded and started
 DEBUG: ui.main - Interface Built
 DEBUG: ui.main - Addons loaded
 INFO: mousetrap - MouseTrap's Interface Built and Loaded
 /usr/local/bin/mousetrap: line 139:  3335 Segmentation fault      (core dumped) /usr/bin/python -c "import mousetrap.app.main as mousetrap; mousetrap.Controller().start();" "$ARGS"

1.8.2013

Error:

 File "mousetrap/ocvfw/_ocv.py", line 332, in get_haar_points
 cascade = co.cv.CvLoadHaarClassifierCascade( haarCascade, self.imgSize )
 AttributeError: 'module' object has no attribute 'CvLoadHaarClassifierCascade'

Fix::

  • LoadHaarClassifier -> Load

Error:

 File "mousetrap/ocvfw/_ocv.py", line 332, in get_haar_points
 cascade = co.cv.Load( haarCascade, self.imgSize )
 AttributeError: Camera instance has no attribute 'imgSize'

Fix:

  • imgSize -> removed

Error:

 File "mousetrap/ocvfw/_ocv.py", line 337, in get_haar_points
 co.cv.Resize( self.img, self.small_img, co.cv.CV_INTER_LINEAR )
 AttributeError: Camera instance has no attribute 'small_img'

Fix:

  • Resize -> cvResize | cvResize -> OK


Receiving new error (same as Logan)

 /usr/lib/python2.7/site-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name)   == 0' failed
 import gobject._gobject
 DEBUG: mousetrap.ocvfw.idm -> Starting Forehead idm
 INFO: mousetrap.ocvfw.idm -> Forhead Algorithm loaded
 DEBUG: mousetrap.ocvfw.idm -> Setting Capture
 DEBUG: Commons -> New Singleton Add (mousetrap.ocvfw.dev.camera.Camera)
 VIDIOC_QUERYMENU: Invalid argument
 VIDIOC_QUERYMENU: Invalid argument
 VIDIOC_QUERYMENU: Invalid argument
 DEBUG: ocvfw -> cmStartCamera: Camera Started
 DEBUG: Camera -> Loaded backend OcvfwPython
 DEBUG: OcvfwBase -> Changed lk_swap value to True
 INFO: mousetrap - Idm loaded and started
 DEBUG: ui.main - Interface Built
 DEBUG: ui.main - Addons loaded
 Problems loading mousetrap.ocvfw.idm.eyes
 INFO: mousetrap - MouseTrap's Interface Built and Loaded
 Traceback (most recent call last):
 File "mousetrap/ocvfw/dev/camera.py", line 116, in sync
   Camera.query_image()
 File "mousetrap/ocvfw/_ocv.py", line 127, in query_image
   self.img            = co.cv.cvCreateImage ( self.imgSize, 8, 3 )
 AttributeError: 'module' object has no attribute 'cvCreateImage'
 Traceback (most recent call last):
 File "mousetrap/app/main.py", line 238, in update_frame
   self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 File "mousetrap/ocvfw/idm/forehead.py", line 128, in get_capture
   self.get_forehead()
 File "mousetrap/ocvfw/idm/forehead.py", line 148, in get_forehead
   face     = self.cap.get_area(commons.haar_cds['Face'])
 File "mousetrap/ocvfw/dev/camera.py", line 373, in get_area
   return Camera.get_haar_points(haar_csd)
 File "mousetrap/ocvfw/_ocv.py", line 337, in get_haar_points
   co.cv.Resize( self.img, self.small_img, co.cv.CV_INTER_LINEAR )
 AttributeError: Camera instance has no attribute 'small_img'
 /usr/local/bin/mousetrap: line 139:  8105 Segmentation fault      (core dumped) /usr/bin/python -c "import mousetrap.app.main as   mousetrap; mousetrap.Controller().start();" "$ARGS"

1.9.2013

Looks like there are some inconsistencies with opencv. Going through and removing outdated methods. I was also looking to see how the camera is initiated, reading through code.

1.11.2013

Was able to get rid of the small_img error after trying several adaptations of opencv methods.

  • cvSize no longer exists and the python tuple (int, int) should be used instead.

Have new error:

 Traceback (most recent call last):
 File "mousetrap/app/main.py", line 238, in update_frame
   self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 File "mousetrap/ocvfw/idm/forehead.py", line 128, in get_capture
   self.get_forehead()
 File "mousetrap/ocvfw/idm/forehead.py", line 148, in get_forehead
   face     = self.cap.get_area(commons.haar_cds['Face'])
 File "mousetrap/ocvfw/dev/camera.py", line 373, in get_area
   return Camera.get_haar_points(haar_csd)
 File "mousetrap/ocvfw/_ocv.py", line 350, in get_haar_points
   co.cv.ClearMemStorage( self.storage )
 AttributeError: 'module' object has no attribute 'ClearMemStorage'
 /usr/local/bin/mousetrap: line 139:  6550 Segmentation fault      (core dumped) /usr/bin/python -c "import mousetrap.app.main as   mousetrap; mousetrap.Controller().start();" "$ARGS"

New error:

 Traceback (most recent call last):
 File "mousetrap/app/main.py", line 238, in update_frame
   self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 File "mousetrap/app/ui/main.py", line 186, in update_frame
   self.cap_image.set_from_pixbuf(cap.to_gtk_buff().scale_simple(200, 160, gtk.gdk.INTERP_BILINEAR))
 File "mousetrap/ocvfw/dev/camera.py", line 194, in to_gtk_buff
   buff = gtk.gdk.pixbuf_new_from_data(img.imageData, 
 AttributeError: 'cv2.cv.iplimage' object has no attribute 'imageData'
 DEBUG: ocvfw -> <iplimage(nChannels=1 width=640 height=480 widthStep=640 )>
 DEBUG: ocvfw -> <iplimage(nChannels=1 width=640 height=480 widthStep=640 )>
 DEBUG: ocvfw -> <iplimage(nChannels=1 width=640 height=480 widthStep=640 )>
 DEBUG: ocvfw -> <iplimage(nChannels=1 width=640 height=480 widthStep=640 )>
 /usr/local/bin/mousetrap: line 139:  6816 Segmentation fault      (core dumped) /usr/bin/python -c "import mousetrap.app.main as mousetrap; mousetrap.Controller().start();" "$ARGS"


1.14.2013

New error:

 /usr/lib/python2.7/site-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
 import gobject._gobject
 DEBUG: Ocvfw -> <module 'mousetrap.ocvfw.idm.forehead' from 'mousetrap/ocvfw/idm/forehead.pyc'>
 DEBUG: mousetrap.ocvfw.idm -> Starting Forehead idm
 INFO: mousetrap.ocvfw.idm -> Forhead Algorithm loaded
 DEBUG: mousetrap.ocvfw.idm -> Setting Capture
 DEBUG: Commons -> New Singleton Add (mousetrap.ocvfw.dev.camera.Camera)
 CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate production trees: Can't create any node of the requested type!
 ^^^^^^^^^^^^^^^^^^^^^^^^
 DEBUG: ocvfw -> cmStartCamera: Camera Started
 DEBUG: Camera -> Loaded backend OcvfwPython
 DEBUG: ocvfw -> None
 DEBUG: OcvfwBase -> Changed lk_swap value to True
 INFO: mousetrap - Idm loaded and started
 DEBUG: ui.main - Interface Built
 DEBUG: ui.main - Addons loaded
 INFO: mousetrap - MouseTrap's Interface Built and Loaded
 /usr/local/bin/mousetrap: line 139:  5613 Segmentation fault      (core dumped) /usr/bin/python -c "import mousetrap.app.main as mousetrap; mousetrap.Controller().start();" "$ARGS"

New error:

 /usr/lib/python2.7/site-  packages/gobject/constants.py:24: Warning:  g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed
 import gobject._gobject
 DEBUG: mousetrap.ocvfw.idm -> Starting Forehead idm
 INFO: mousetrap.ocvfw.idm -> Forhead Algorithm   loaded
 DEBUG: mousetrap.ocvfw.idm -> Setting Capture
 DEBUG: Commons -> New Singleton Add    (mousetrap.ocvfw.dev.camera.Camera)
 VIDIOC_QUERYMENU: Invalid argument
 VIDIOC_QUERYMENU: Invalid argument
 VIDIOC_QUERYMENU: Invalid argument
 DEBUG: ocvfw -> cmStartCamera: Camera Started
 DEBUG: Camera -> Loaded backend OcvfwPython
 DEBUG: OcvfwBase -> Changed lk_swap value to True
 INFO: mousetrap - Idm loaded and started
 DEBUG: ui.main - Interface Built
 DEBUG: ui.main - Addons loaded
 INFO: mousetrap - MouseTrap's Interface Built and   Loaded
 Help on iplimage object:
 class iplimage(__builtin__.object)
 Methods defined here:
 
 __delitem__(...)
     x.__delitem__(y) <==> del x[y]
 
 __getitem__(...)
     x.__getitem__(y) <==> x[y]
 
 __repr__(...)
     x.__repr__() <==> repr(x)
 
 __setitem__(...)
     x.__setitem__(i, y) <==> x[i]=y
 
 tostring(...)
 
 ----------------------------------------------------------------------
 Data descriptors defined here:
 
 channels
     nChannels
 
 depth
     depth
 
 height
     height
 
 nChannels
    nChannels
 
 origin
    origin
 
 width
     width
 
 ----------------------------------------------------------------------
 Data and other attributes defined here:
 
 __new__ = <built-in method __new__ of type object>
     T.__new__(S, ...) -> a new object with type S, a subtype of T

 DEBUG: ui.main - None
 DEBUG: ui.main -> None
 Traceback (most recent call last):
 File "mousetrap/app/main.py", line 238, in update_frame
   self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 File "mousetrap/app/ui/main.py", line 186, in update_frame
       self.cap_image.set_from_pixbuf(cap.to_gtk_buff().sc  ale_simple(200, 160, gtk.gdk.INTERP_BILINEAR))
 File "mousetrap/ocvfw/dev/camera.py", line 195, in to_gtk_buff
   buff = gtk.gdk.pixbuf_new_from_data(img.data, 
 AttributeError: 'cv2.cv.iplimage' object has no   attribute 'data'
 /usr/local/bin/mousetrap: line 139:  2209   Segmentation fault      (core dumped)   /usr/bin/python -c "import mousetrap.app.main as mousetrap; mousetrap.Controller().start();" "$ARGS"


  • Fix: replaced imageData with tostring()

1.15.2013

New error:

 Traceback (most recent call last):
 File "mousetrap/app/main.py", line 238, in update_frame
   self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 File "mousetrap/app/ui/main.py", line 186, in update_frame
   self.cap_image.set_from_pixbuf(cap.to_gtk_buff().scale_simple(200, 160, gtk.gdk.INTERP_BILINEAR))
 File "mousetrap/ocvfw/dev/camera.py", line 198, in to_gtk_buff
   img.widthStep )
 AttributeError: 'cv2.cv.iplimage' object has no attribute 'widthStep'
 /usr/local/bin/mousetrap: line 139:  3991 Segmentation fault      (core dumped) /usr/bin/python -c "import mousetrap.app.main as mousetrap; mousetrap.Controller().start();" "$ARGS"
  • Fix widthStep does not exist, use width


1.16.2013

New Error:

 Traceback (most recent call last):
 File "mousetrap/app/main.py", line 238, in update_frame
   self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 File "mousetrap/ocvfw/idm/forehead.py", line 127, in get_capture
   self.get_forehead()
 File "mousetrap/ocvfw/idm/forehead.py", line 147, in get_forehead
   face     = self.cap.get_area(commons.haar_cds['Face'])
 File "mousetrap/ocvfw/dev/camera.py", line 373, in get_area
   return Camera.get_haar_points(haar_csd)
 File "mousetrap/ocvfw/_ocv.py", line 350, in get_haar_points
   for r in points]
 AttributeError: 'module' object has no attribute 'Point'
 /usr/local/bin/mousetrap: line 139:  4940 Segmentation fault      (core dumped) /usr/bin/python -c "import mousetrap.app.main as mousetrap; mousetrap.Controller().start();" "$ARGS"
  • Point no longer exists in the python version of the api. Now tuples are used. Looking into how the points are used in the program to see if it can be changed.

1.17.2013

1.21.2013

  • Fixed most of the Point errors; make sure cvPoint is just a python tuple
  • Load() is the new cvLoadHaarClassifierCascade()
  • The points variable in _ocv.py looks like this: ((173, 130, 145, 145), 15) but it is used as if it was a series of points, so that was changed to r[0][0] and so forth.

Some examples of point errors/changes:

Error

 Traceback (most recent call last):
 File "mousetrap/app/main.py", line 238, in update_frame
   self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 File "mousetrap/ocvfw/idm/forehead.py", line 127, in get_capture
   self.get_forehead()
 File "mousetrap/ocvfw/idm/forehead.py", line 163,  in get_forehead
   areas = [ (pt[1].x - pt[0].x)*(pt[1].y - pt[0].y) for pt in eyes ]

Changes

 if eyes:
    areas = [ (pt[1][0] - pt[0][0])*(pt[1][1] - pt[0][1]) for pt in eyes ] #replaced x with [0] and y with [1]

1.23.2013

New Error:

 OpenCV Error: Incorrect size of input array () in cvGetSubRect, file /builddir/build/BUILD/OpenCV-2.3.1/modules/core/src/array.cpp, line 1262             
 Traceback (most recent call last):                                           
 File "mousetrap/app/main.py", line 238, in update_frame                    
   self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())    
 File "mousetrap/ocvfw/idm/forehead.py", line 127, in get_capture           
   self.get_forehead()                                                      
 File "mousetrap/ocvfw/idm/forehead.py", line 160, in get_forehead
   "height" : endF[1] - startF[1]}, (startF[0], startF[1]) )# replaced x and y
 File "mousetrap/ocvfw/dev/camera.py", line 378, in get_area
   return Camera.get_haar_roi_points(haar_csd, roi, orig)
 File "mousetrap/ocvfw/_ocv.py", line 378, in get_haar_roi_points
   imageROI = co.cv.GetSubRect(self.img, rect)
 cv2.error
 * had to change some of the code for points, so this could have resulted from that, but I'm not sure what it's particularly building...any ideas?

The parameters of the self.image are: <iplimage(nChannels=3 width=640 height=480 widthStep=1920 )>

The rect parameters are: (318, 190, 205, 333)

Getting Closer...

  • It is detecting objects and I have it printing the specs, so it's finding some..
 DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 DEBUG: ocvfw -> <iplimage(nChannels=3 width=640 height=480 widthStep=1920 )>
 DEBUG: ocvfw -> (243, 192, 229, 280)
 DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 DEBUG: ocvfw -> <iplimage(nChannels=3 width=640 height=480 widthStep=1920 )>
 DEBUG: ocvfw -> (237, 184, 243, 296)
 DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 DEBUG: ocvfw -> <iplimage(nChannels=3 width=640 height=480 widthStep=1920 )>
 DEBUG: ocvfw -> (240, 186, 240, 294)
 DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 DEBUG: ocvfw -> <iplimage(nChannels=3 width=640 height=480 widthStep=1920 )>
 DEBUG: ocvfw -> (243, 190, 234, 287)
 DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 DEBUG: ocvfw -> <iplimage(nChannels=3 width=640 height=480 widthStep=1920 )>
 DEBUG: ocvfw -> (240, 189, 238, 289)
 DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
 DEBUG: ocvfw -> <iplimage(nChannels=3 width=640 height=480 widthStep=1920 )>
 DEBUG: ocvfw -> (241, 190, 234, 285)
 DEBUG: ocvfw -> ((46, 71, 93, 43), 3)
 DEBUG: ocvfw -> cmGetHaarROIPoints: detected some matches

Current error with optical flow:

 optical_flow = co.cv.CalcOpticalFlowPyrLK (
           self.prevGrey, self.grey, self.prevPyramid, self.pyramid,
           self.img_lkpoints["last"], len( self.img_lkpoints["last"] ),
           (20, 20), 3, len( self.img_lkpoints["last"] ), None,
           (co.cv.CV_TERMCRIT_ITER|co.cv.CV_TERMCRIT_EPS, 20, 0.03), 0)


1.24.2013

  • TermCriteria doesn't exist, and there's little documentation on the method on how to create the calculation for optical flow for the new version of cv.

Description of CalcOpticalFlowPyrLK()

  • Does not have an example or descriptive errors when fails.
 Parameters:	
 prevImg – first 8-bit input image or pyramid constructed by buildOpticalFlowPyramid().
 nextImg – second input image or pyramid of the same size and the same type as prevImg.
 prevPts – vector of 2D points for which the flow needs to be found; point coordinates must be single-precision floating-point numbers.
 nextPts – output vector of 2D points (with single-precision floating-point coordinates) containing the calculated new positions of input features in the second image; when OPTFLOW_USE_INITIAL_FLOW flag is passed, the vector must have the same size as in the input.
 status – output status vector; each element of the vector is set to 1 if the flow for the corresponding features has been found, otherwise, it is set to 0.
 err – output vector of errors; each element of the vector is set to an error for the corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn’t found then the error is not defined (use the status parameter to find such cases).
 winSize – size of the search window at each pyramid level.
 maxLevel – 0-based maximal pyramid level number; if set to 0, pyramids are not used (single level), if set to 1, two levels are used, and so on; if pyramids are passed to input then algorithm will use as many levels as pyramids have but no more than maxLevel.
 criteria – parameter, specifying the termination criteria of the iterative search algorithm (after the specified maximum number of iterations criteria.maxCount or when the search window moves by less than criteria.epsilon.
 flags –
 operation flags:
 OPTFLOW_USE_INITIAL_FLOW uses initial estimations, stored in nextPts; if the flag is not set, then prevPts is copied to nextPts and is considered the initial estimate.
 OPTFLOW_LK_GET_MIN_EIGENVALS use minimum eigen values as an error measure (see minEigThreshold description); if the flag is not set, then L1 distance between patches around the original and a moved point, divided by number of pixels in a window, is used as a error measure.
 minEigThreshold – the algorithm calculates the minimum eigen value of a 2x2 normal matrix of optical flow equations (this matrix is called a spatial gradient matrix in [Bouguet00]), divided by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding feature is filtered out and its flow is not processed, so it allows to remove bad points and get a performance boost


1.25.2013

New Error:

 Traceback (most recent call last):
 File "mousetrap/app/main.py", line 238, in update_frame
   self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 File "mousetrap/ocvfw/idm/forehead.py", line 127, in get_capture
   self.get_forehead()
 File "mousetrap/ocvfw/idm/forehead.py", line 171, in get_forehead
   self.cap.add( Point("point", "forehead", ( X, Y ), parent=self.cap, follow=True) )
 File "mousetrap/ocvfw/dev/camera.py", line 333, in add
   Camera.set_lkpoint(graphic)
 File "mousetrap/ocvfw/_ocv.py", line 166, in set_lkpoint
   (co.cv.CV_TERMCRIT_ITER | co.cv.CV_TERMCRIT_EPS, 20, 0.03))
 TypeError: CvSize argument 'zero_zone' expects two integers
 Traceback (most recent call last):
 File "mousetrap/ocvfw/dev/camera.py", line 131, in sync
   Camera.show_lkpoints()
 File "mousetrap/ocvfw/_ocv.py", line 205, in show_lkpoints
   (co.cv.CV_TERMCRIT_ITER|co.cv.CV_TERMCRIT_EPS, 20, 0.03), 0)
 TypeError: Expected tuple for CvPoint2D32f argument 'prev_features'

/usr/local/bin/mousetrap: line 139: 4335 Segmentation fault (core dumped) /usr/bin/python -c "import mousetrap.app.main as mousetrap; mousetrap.Controller().start();" "$ARGS"

Which is testing the actual method, and it still shows an error.

1.28.2013

  • I've been playing around with cv2 and trying to get a test file running and encountered a possible future error with the api.

Apparently, it cannot work for all video drivers, and might potentially not work for mine. It's discussed here in this thread: http://stackoverflow.com/questions/11420748/setting-camera-parameters-in-opencv-python

Error:

 [root@amber src]# python testcv.py 
 VIDIOC_QUERYMENU: Invalid argument
 VIDIOC_QUERYMENU: Invalid argument
 VIDIOC_QUERYMENU: Invalid argument
 VIDIOC_QUERYMENU: Invalid argument
 VIDIOC_QUERYMENU: Invalid argument
 VIDIOC_QUERYMENU: Invalid argument
 HIGHGUI ERROR: V4L: Property Exposure(15) not supported by device
 VIDIOC_QUERYMENU: Invalid argument
 VIDIOC_QUERYMENU: Invalid argument                                          
 VIDIOC_QUERYMENU: Invalid argument                                          
 libv4l2: error setting pixformat: Device or resource busy                   
 HIGHGUI ERROR: libv4l unable to ioctl S_FMT                                 
 libv4l2: error setting pixformat: Device or resource busy                   
 libv4l1: error setting pixformat: Device or resource busy                   
 HIGHGUI ERROR: libv4l unable to ioctl VIDIOCSPICT

 CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate production trees: Can't create any node of the requested type!

It has something to do with the exposure times (so the camera will endlessly capture video)

  • Here is a little program that will capture video from the webcam and display it (endlessly unless you CTRL+C)
 """
 This module is used for testing the opencv2 capabilities
 """
 import cv2
 #get webcam feed
 capture = cv2.VideoCapture(0)
 while True:
     #combines VideoCapture.grab() and VideoCapture.retrieve()
     retrieval_value, image = capture.read()
     #shows captured image in a window
     cv2.imshow("webcam", image)
     #will stop capture with capatible webcam
     if cv2.waitKey(10) == 27:
         break


1.29.2013

 * this is the new version (completely remodeled) pyopencv: http://code.google.com/p/pyopencv/

1.31.2013

2.4.2013

Now I have a repeating line and nothing happens. It could be that my webcam isn't compatible. Here's the error.

 DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
  • I noticed that the blank window that always appears is a gtk window object and should be displaying a menu, so I started using the command line python utility to fuss around with gtk and see if I can replicate something and try to fix the code in MT.

2.5.2013

Receiving a new error:

 DEBUG: ocvfw -> cmGetHaarROIPoints: detected some matches
 Traceback (most recent call last):
 File "mousetrap/app/main.py", line 238, in update_frame
   self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 File "mousetrap/ocvfw/idm/forehead.py", line 127, in get_capture
   self.get_forehead()
 File "mousetrap/ocvfw/idm/forehead.py", line 174, in get_forehead
   self.cap.add( Point("point", "forehead", ( X, Y ), parent=self.cap, follow=True) )
 File "mousetrap/ocvfw/dev/camera.py", line 333, in add
   Camera.set_lkpoint(graphic)
 File "mousetrap/ocvfw/_ocv.py", line 167, in set_lkpoint
   (co.cv.CV_TERMCRIT_ITER | co.cv.CV_TERMCRIT_EPS, 20, 0.03))
 TypeError: CvSize argument 'zero_zone' expects two integers
 DEBUG: Ocvfw -> {'current': [], 'points': [], 'last': [2618, 17866]}
 Traceback (most recent call last):
 File "mousetrap/ocvfw/dev/camera.py", line 131, in sync
   Camera.show_lkpoints()
 File "mousetrap/ocvfw/_ocv.py", line 211, in show_lkpoints
   self.img_lkpoints["current"], status = optical_flow
 ValueError: too many values to unpack

The list it is unpacking is: {'current': [], 'points': [], 'last': [3632, 19477]}

2.6.2013

New error after changing optical flow calculation to cv2

 OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /builddir/build/BUILD/OpenCV-2.3.1/modules/imgproc/src/color.cpp, line 2834
 Traceback (most recent call last):
 File "mousetrap/ocvfw/dev/camera.py", line 131, in sync
   Camera.show_lkpoints()
 File "mousetrap/ocvfw/_ocv.py", line 204, in show_lkpoints
   prevGrey = cv2.cvtColor(self.prevGrey, cv2.COLOR_BGR2GRAY)
 cv2.error: /builddir/build/BUILD/OpenCV-2.3.1/modules/imgproc/src/color.cpp:2834: error: (-215) scn == 3 || scn == 4 in function cvtColor

2.8.2013

  • Per request: Opencv has been first released in 2006 with its 1.0 version, the latest version 2.4.3 was released in march of 2012. On the horizon is a rumored that OpenCV 2.5 will release an aggregate "opencv_world" module which will be the whole OpenCV library in single so/dll/dylib file, but when that will happen is unknown.

2.11.2013

2.14.2013

New Error

 DEBUG: Ocvfw -> <iplimage(nChannels=3 width=640 height=480 widthStep=1920 )>
 Traceback (most recent call last):
 File "mousetrap/app/main.py", line 238, in update_frame
   self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
 File "mousetrap/ocvfw/idm/forehead.py", line 127, in get_capture
   self.get_forehead()
 File "mousetrap/ocvfw/idm/forehead.py", line 147, in get_forehead
   face     = self.cap.get_area(commons.haar_cds['Face'])
 File "mousetrap/ocvfw/dev/camera.py", line 373, in get_area
   return Camera.get_haar_points(haar_csd)
 File "mousetrap/ocvfw/_ocv.py", line 352, in get_haar_points
   cv2.resize( self.img, self.small_img, cv.CV_INTER_LINEAR )
 TypeError: <unknown> is not a numpy array
 Traceback (most recent call last):
 File "mousetrap/ocvfw/dev/camera.py", line 127, in sync
   self.__image = self.color(self.__color_set)
 File "mousetrap/ocvfw/dev/camera.py", line 294, in color
   co.cv.CvtColor( self.__image, tmp, self.__color_int['cv_%s2%s' % (self.__color, new_color) ])
 TypeError: CvArr argument 'src' must be IplImage, CvMat or CvMatND. Use fromarray() to convert numpy arrays to CvMat or cvMatND
  • Need to decide whether to use IplImages or numpy arrays.

2.15.2013

Installing Fedora 18

1) Created bootable flash drive using: sudo dd if=FEDORA.ISO of=/dev/DRIVE# bs=8M conv=fsync

2) Boot with flashdrive

- No problems


2.19.2013

  • I decided that I'm going to put a full install method here and on the dev page.

Complete Git + Mousetrap Install

Let's get git
 Open a terminal, become root
 Run Commands:
 -> cd /opt
 -> mkdir git  (just fyi you can put your repo anywhere, this is just how I was taught)
 -> yum install git-core
 -> cd /opt/git
 -> git clone git://github.com/amberheilman/mousetrap.git
 * Now you have pulled down the git repo
 -> cd mousetrap
 -> git checkout fix_install (my branch)
 -> git pull
 * DO NOT MAKE CHANGES HERE
 * We should all be working in separate branches!
Make a branch:
 -> git branch INSERT_BRANCH_NAME      * this clones my branch and creates a new one
 -> git checkout INSERT_BRANCH_NAME    * this opens up your branch that you just created
 -> git branch                         * now you can see the branch your in with a *, and all others under this git repo
Mousetrap Install method
 Install Dependencies:
 -> yum install gnome-common
 -> yum install glib2-devel
 -> yum install intltool
 -> yum install python-devel
 -> yum install opencv-python
 -> yum install python-xlib
 Run Commands:
 -> cd /opt/git/mousetrap/src          * THIS WILL NOT WORK OUTSIDE THIS DIR!
 -> cd ..
 -> ./autogen.sh
 -> make
 -> make install
 -> mousetrap                          * You may have errors but they should be similar to my own (towards the end)
Make your first commit
 -> git status                         * Shows all of the modified files
 -> git add *                          * This is to add ALL files to commit list (MAKE SURE YOU WANT THEM ALL FIRST!)
 -> git commit                         * Add a useful title to first line of your commit.
                                         This is in vim so 'i' to insert ':x' to save and quit.
 -> git push origin INSERT_BRANCH_NAME * This must be the branch you created in the git install.
                                         This will ask for your git credentials, so have them ready.


Status CURRENT


8.4.2013

I am running into the segfault issue that Logan was talking about.


Logan Status

To make it easier to edit and follow, I have moved my updates to a new page: Logan Status Updates

John Status

12/29/12

  • Noted that mousetrap and gnome-mousetrap are in the Ubuntu repository. Ignoring this and following instructions provided by the MouseTrap GNOME Live! project page…
  • Installation went as expected. Ran into every issue in the 'Troubleshooting' table, but that seems to be expected behavior.
  • Running MouseTrap with command 'mousetrap'. Expected errors due to lack of webcam. Otherwise seems to run without issue (preferences window pops up when button clicked, and so forth).
  • Quits without issue.

Thoughts on Install Process:

  • Noted that it might be nice if they add the commands for the RPM package manager to the instructions.
  • "Troubleshooting" should be a link to the Troubleshooting section for user-friendliness.
  • 'Dependency hell' is tedious. Due to the fact that MouseTrap is in the Ubuntu repositories suggests it might be in others as well. It might be useful to include this fact in the install instructions.
  • Else it might be useful for the autogen.sh shell file to automatically detect if a package is installed (it already does this) and installs them if they are not. This will run into an issue with different package management systems. A different shell file for the popular ones (APT and RPM)?
  • A GUI installer would be the most user-friendly, but that's not the Linux MO.

1/13/13

  • Webcam received and set up. Seems to be recognized OOTB on Ubuntu -- the light goes on when in use, etc.
  • When running Mousetrap, it shows a blank window (most of the time) or a frozen video frame (only seen this once). In the terminal, it repeatedly displays errors similar to this;
Corrupt JPEG data: 1 extraneous bytes before marker 0xd9
  • When running again with webcam unplugged, it runs fine.

1/25/13

Replaced Ubuntu with Fedora 18 on system. Webcam works out of the box. Everything works nicely. Except for the new UI for Anaconda, but I digress. Had issues installing Mousetrap. Full details below...

Installing Fedora:

I downloaded the ISO image for the Fedora 18 Network Install CD from here http://fedoraproject.org/en/get-fedora-options#formats. This is good if you have fast internet access. This is ideal since a) it's a small(er) download, and b) dd takes a while (see below).

Instead of a CD/DVD, I decided to use a USB stick. I used the Fedora-suggested LiveUSB tool, but it produced a USB stick that either a) is not recognized as bootable, or b) freezes at or after the "Secure boot not enabled" screen. So I used dd instead (a nifty tool, which should already be installed if you're using a UNIX-based OS, that copies a disk image to a destination byte-for-byte). To put the .iso image onto my USB stick, I used the command,

# dd if=./Fedora-18-x86_64-netinst.iso of=/etc/rdisk1

I had to be root to do this (hence the # above). Note that I also put "r" before the device name (in the above example, I used rdisk1 instead of disk1). This enables direct access, which speeds things up considerably. I used

$ fdisk -l

to find out the location of the USB drive.

Once I executed the dd command, it sat there seemingly doing nothing. dd can take a while (hence the reason I didn't use the Live DVD ISO!).

After it was done, booted from the USB drive, followed the (horrid) Anaconda installation process (beware of the terrifying partitioning part!).

After that's done, booted up and installed the b43 driver for my wireless card using the guide here, http://linuxwireless.org/en/users/Drivers/b43#Fedora. Everything works great, including the webcam.

Installing Mousetrap:

I attempted to install all the dependencies listed on the Mousetrap GNOME Live! site using the usual yum install <package>. However pygtk, python-pyspi and libglib2.0 are not in the repos.

  Install method
 Install Dependencies:
 * gnome-common
 * glib2-devel
 * intltool
 * python-devel
 * opencv-python
 * python-xlib
 Run Commands:
 -> run git branch fix_install
 -> run ./autogen.sh
 -> make
 -> make install
 -> run mousetrap from /src
 (let me know if this works for you --Amber)

2/8/13

Installed Mousetrap successfully via Amber's instructions above. Ran into an error;

 ImportError: could not import gobject (error was: ImportError('When using gi.repository you must not import static modules 
 like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject".',))

2/16/13

Started on learning the Python language using "Learning Python, 4th Edition."

 I don't think that you are in the correct branch. You downloaded a clone via git, right?
 I put up an entire install method, see if you missed something.

4/21/13

NOTES TO SELF:

Worked on getting OpenCV webcam view into GTK+ UI.

Wrote a very simple program using straight OpenCV API. Works fine.

Wrote a GTK+ based program that takes a photo via the webcam and saves it as a file. Also works fine.

With those experiences in my belt, I tried integrating the two, to little success.

Yes, I've tried using the photo program I wrote above to brute-force a display of a video via a loop -- but knew before I begun that it's a horribly bad (and potentially dangerous!) idea.

Googling keeps leading me to GdkPixBuf (previously gtk.gdk.PixBuf in PyGTK). Requires iplimage (used by OpenCV) to be converted into PIL (Python Image Language) before it can be converted into PixBuf via new_from_data. OpenCV used to have adaptors that can do this, but it was, for some reason, deprecated with no equivalent replacement.

There's some nonsense about NumPy and/or Matlibplot as well.

But all of this is moot for the time being due to finding out that the new_from_data API seems to be broken for Python -- http://stackoverflow.com/questions/10284465/gdkpixbuf-pixbufdestroynotify-notimplementederror-python-gtk3

One possible alternative is to use new_from_array, creating an array from the image via Array (or NumPy array, not sure). But I haven't looked too deeply on how to a) convert an iplimage to a PIL then/or to an array, and b) how to use new_from_array.

Another possible alternative -- due to OpenCV using a Qt backend -- is to use Plug() and Socket() in GTK+ to embed the OpenCV window into a GTK+ window. Haven't figured out how to do this due to OpenCV's limited UI API. Maybe a Qt API can interact with windows created by OpenCV?

Another alternative; I checked out Cheese (a open source Photobooth rip off that comes preinstalled with Fedora) -- turns out it uses Gstreamer to capture images from the webcam. As Gstreamer works great with GTK+, perhaps one solution would be to use Gstreamer for the UI, and OpenCV for the background heavy-lifting?

4/30/13

After the discussion on Friday of how MouseTrap was supposed to work, and whether it even worked "in the wild" at all, I decided to compile it and see what I can find out with all that I've learned in the past few months in the hopes of gathering some useful information for future use.

We know that MouseTrap compiles in Ubuntu 10.4, so I installed Ubuntu 10.4 on a virtual machine, and followed the instructions on the MouseTrap GNOME Live! webpage. Additionally, I compiled Mousetrap with the --enable-doxygen and --enable-docbook flags (from the bottom of the installation instructions page) to get the doxygen-generated developer documentation and user documentation, respectively. Those are not obtainable without compiling MouseTrap, and we all know it does not compile in Fedora 18.

The user documentation (docbook) and doxygen-generated documentation are on my GitHub repo; ([1])

Additionally, I ran Mousetrap multiple times, and found three "scenarios", each occurring at random. I have documented the "scenarios" below.


The first scenario is where Mousetrap runs, and displays a frozen captured frame from the webcam, and nothing else. The output in the terminal is as follows:

john@john-desktop:~/mousetrap$ mousetrap
Xlib.protocol.request.QueryExtension
DEBUG: mousetrap.ocvfw.idm -> Starting Forehead idm
INFO: mousetrap.ocvfw.idm -> Forhead Algorithm loaded
DEBUG: mousetrap.ocvfw.idm -> Setting Capture
DEBUG: Commons -> New Singleton Add (mousetrap.ocvfw.dev.camera.Camera)
DEBUG: ocvfw -> cmStartCamera: Camera Started
DEBUG: Camera -> Loaded backend OcvfwPython
DEBUG: OcvfwBase -> Changed lk_swap value to True
INFO: mousetrap - Idm loaded and started
DEBUG: ui.main - Interface Built
DEBUG: ui.main - Addons loaded
INFO: mousetrap - MouseTrap's Interface Built and Loaded
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/dev/camera.py", line 116, in sync
    Camera.query_image()
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/_ocv.py", line 140, in query_image
    co.cv.cvCvtColor(self.img, self.grey, co.cv.CV_BGR2GRAY)
  File "/usr/lib/pymodules/python2.6/opencv/cv.py", line 6759, in cvCvtColor
    return _cv.cvCvtColor(*args)
RuntimeError:  openCV Error:
        Status=Null pointer
        function name=cvGetMat
        error message=NULL array pointer is passed
        file_name=cxcore/cxarray.cpp
        line=2370
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/app/main.py", line 238, in update_frame
    self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/idm/forehead.py", line 128, in get_capture
    self.get_forehead()
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/idm/forehead.py", line 148, in get_forehead
    face     = self.cap.get_area(commons.haar_cds['Face'])
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/dev/camera.py", line 373, in get_area
    return Camera.get_haar_points(haar_csd)
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/_ocv.py", line 340, in get_haar_points
    co.cv.cvResize( self.img, self.small_img, co.cv.CV_INTER_LINEAR )
  File "/usr/lib/pymodules/python2.6/opencv/cv.py", line 6763, in cvResize
    return _cv.cvResize(*args)
RuntimeError:  openCV Error:
        Status=Null pointer
        function name=cvGetMat
        error message=NULL array pointer is passed
        file_name=cxcore/cxarray.cpp
        line=2370

Screenshot: Screenshot1.png


The second scenario is where Mousetrap runs, with no image displayed. The output in the terminal is as follows:

john@john-desktop:~$ mousetrap
Xlib.protocol.request.QueryExtension
DEBUG: mousetrap.ocvfw.idm -> Starting Forehead idm
INFO: mousetrap.ocvfw.idm -> Forhead Algorithm loaded
DEBUG: mousetrap.ocvfw.idm -> Setting Capture
DEBUG: Commons -> New Singleton Add (mousetrap.ocvfw.dev.camera.Camera)
DEBUG: ocvfw -> cmStartCamera: Camera Started
DEBUG: Camera -> Loaded backend OcvfwPython
DEBUG: OcvfwBase -> Changed lk_swap value to True
INFO: mousetrap - Idm loaded and started
DEBUG: ui.main - Interface Built
DEBUG: ui.main - Addons loaded
INFO: mousetrap - MouseTrap's Interface Built and Loaded
Corrupt JPEG data: 5113 extraneous bytes before marker 0xd2
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/dev/camera.py", line 116, in sync
    Camera.query_image()
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/_ocv.py", line 129, in query_image
    self.imgSize        = co.cv.cvGetSize (frame)
  File "/usr/lib/pymodules/python2.6/opencv/cv.py", line 4350, in cvGetSize
    return _cv.cvGetSize(*args)
RuntimeError:  openCV Error:
        Status=Bad argument
        function name=cvGetSize
        error message=Array should be CvMat or IplImage
        file_name=cxcore/cxarray.cpp
        line=1227
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/app/main.py", line 238, in update_frame
    self.itf.update_frame(self.idm.get_capture(), self.idm.get_pointer())
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/idm/forehead.py", line 128, in get_capture
    self.get_forehead()
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/idm/forehead.py", line 148, in get_forehead
    face     = self.cap.get_area(commons.haar_cds['Face'])
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/dev/camera.py", line 373, in get_area
    return Camera.get_haar_points(haar_csd)
  File "/usr/local/lib/python2.6/dist-packages/mousetrap/ocvfw/_ocv.py", line 335, in get_haar_points
    cascade = co.cv.cvLoadHaarClassifierCascade( haarCascade, self.imgSize )
AttributeError: Camera instance has no attribute 'imgSize'

Screenshot: Screenshot2.png


The third scenario, which is rare compared to the above two, is rather interesting. Mousetrap begins with a completely blank window (no widgets, only the title bar) and hijacks the mouse. Most of the time, the mouse is stuck at the lower left corner, but occasionally it would flicker around the screen (no smooth motion, it simply appears and disappears at seemingly random points). This is not in response to the webcam feed as far as I could tell. The behavior does not change even when the webcam is covered. There is also no way to exit the program; I had to do a killall.

The terminal output is:

john@john-desktop:~$ mousetrap
Xlib.protocol.request.QueryExtension
DEBUG: mousetrap.ocvfw.idm -> Starting Forehead idm
INFO: mousetrap.ocvfw.idm -> Forhead Algorithm loaded
DEBUG: mousetrap.ocvfw.idm -> Setting Capture
DEBUG: Commons -> New Singleton Add (mousetrap.ocvfw.dev.camera.Camera)
DEBUG: ocvfw -> cmStartCamera: Camera Started
DEBUG: Camera -> Loaded backend OcvfwPython
DEBUG: OcvfwBase -> Changed lk_swap value to True
INFO: mousetrap - Idm loaded and started
DEBUG: ui.main - Interface Built
DEBUG: ui.main - Addons loaded
INFO: mousetrap - MouseTrap's Interface Built and Loaded
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
Corrupt JPEG data: 1372 extraneous bytes before marker 0xd2
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches
DEBUG: ocvfw -> cmGetHaarPoints: detected some matches

... and so on infinitely.

Nicole's Status

1.25.2013

Fedora 18 was successfully installed. Instructions are now on the "Getting Started" page.

2.5.2013

MouseTrap was fully installed. Instructions are now on the "Getting Started" page. I encountered the same first error:

 ImportError: could not import gobject (error was: ImportError('When using gi.repository you must not import static modules 
 like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject".',))
  • Amber, have you put up your latest fork onto your github yet?
 Yes, do you have git installed? (Not really sure how much git you know, so I'll just put up instructions for all.)
 If not, open a terminal, become root
 cd to /opt
 mkdir git  (just fyi you can put your repo anywhere, this is just how I was taught)
 run yum install git-core
 cd into git folder
 run git clone git://github.com/amberheilman/mousetrap.git
 now you have pulled down my code.
 To start using the code I'm currently working on:
 run:
 git checkout fix_install (my branch)
 git pull
 * DO NOT MAKE CHANGES HERE (we should all be working in separate branches)
 git branch INSERT_BRANCH_NAME (this clones my branch and creates a new one)
 git checkout INSERT_BRANCH_NAME (this opens up your branch that you just created)
 git branch (now you can see the branch your in with a *, and all others under this git repo)
 * We should also be making commits on a frequent basis with commit titles that show exactly what was changed
 * Hope this helps
   @Amber from Stoney: It sounds like you're suggesting that Nicole share your repository.
   If so, she'll need to create a GitHub account, and you'll need to add her as a contributor on your fork.
   (cont.) Alternatively, when Nicole has something to contribute, she could make a patch and send it to you.
   (cont.) Another alternative, Nicole could fork your fork using GitHub (she'll need to create an account).
   When she has something to contribute, she can make a pull request to your fork, you can review the changes
   and accept/reject. Directions/tutorial for this approach are here: https://help.github.com/articles/fork-a-repo .

2.7.2013

Made my own github account and forked off of amber's at: https://github.com/WNEmousetrap/mousetrap

Ran mousetrap and now getting error:

Traceback (most recent call last):
 File "<string>", line 1, in <module>
 File "mousetrap/app/main.py", line 42, in <module>
   import environment as env
ImportError: No module named environment
 NOTE: Remember even if you download my code you still need to run the install
 so cd into the git repo /mousetrap and do a ./autogen.sh which checks to make sure
 your dependencies are there (see what I wrote to john). Then you will have to run "make"
 after that is done run "sudo make install"
 Then you should be able to cd to /mousetrap/src and type "mousetrap" to run the program. Otherwise
 it will give you errors like above because files were not created by the make command.
 *Side note:, if you would like to be added to my fork I can do that easily, just send me your username.
 Plus I think it will be easier for us all to communicate if we're working off of the same repo. (-Amber)

2.12.2013

Started to document OpenCV using the information at http://docs.opencv.org/ . I'm starting right with the Introduction and reading through. Trying to get definitions and history from here as much as I can.

2.13.2013

Continuing documentation. Found a few sources towards the community. Getting into reading about API Concepts currently.

2.15.2013

Started looking at OpenCV 2 documentation. Organized the Dev Help page. Starting to focus on CV 2 documentation for now, most of the general information seems to be the same anyways.

2.19.2013

Found the meeting notes from the OpenCV community; starting to read through them with the first meeting notes starting in 2008 (http://code.opencv.org/projects/opencv/wiki/Meeting_notes)

  • stopped at 2009-02-03 for now

2.20.2013

Continued with meeting notes -

2.21.2013

Meeting notes - stopped at 2009-06-02 for now.

3.28.2013

Started to look into what the Makefiles in mousetrap really do; looking through the pdf slides for GNU "autotools" from http://www.lrde.epita.fr/~adl/autotools.html

3.30.2013

Continued reading through slideshow.

4.2.2013

Finished slideshow in preparation for the sprint on Friday. Started researching on Gnome's site to see how they talk about autotools for their projects.

4.4.2013

Found a few things on the Gnome site:

  1. A basic Gnome project tutorial: https://developer.gnome.org/anjuta-build-tutorial/stable/index-info.html.en REALLY GOOD!!
  2. A suggestion for a "modernized" autotools: https://live.gnome.org/GnomeGoals/ModernAutotools
  3. The site does bump me back to the original pdf slideshow that I read through. This is a good sign!!
The basic tutorial is very good to read through. It is a little smaller than the pdf so it would take much less time to get through, 
but it  still has great information. I still recommend reading through at least parts of the pdf if you have time, but the tutorial is an 
EXCELLENT starting point!

4.5.2013

Mousetrap Sprint all day!! Worked on understanding Makefiles.am's and created a Directory Tree for whole mousetrap folder (not just src) and accompanying Makefile.am's in those directories if they existed.

Makefile Tree

4.11.2013

Starting to work through unit testing the "app" and GUI section of the project. Reading up on how gtk works and how the code should look. Will then look at the mousetrap code and add in the functionality that they have to see where the program "breaks."

  • When only trying to write a file to import gtk I got the error:
Traceback (most recent call last):
  File "gtk_test.py", line 1, in <module>
    import gtk
  File "/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py", line 40, in <module>
    from gtk import _gtk
ImportError: /lib64/libEGL.so.1: undefined symbol: wl_display_dispatch_queue_pending


4.12.2013

Still reading through the tutorial about gtk. Going to try to make a small test program for a sample gtk application. Also looking into fixing the gtk import issue.

Fixed the gtk issue! It was a simple version issue. All I needed to do was run:

sudo yum update libwayland-server
sudo yum update libwayland-client

The version I was on was 1.0.0. A new symbol was added in 1.0.2. The most recent version out is 1.0.5.

I managed to create a small working gtk application window!!! Below is the code you can put into a test file (such as mine "gtk_sample.py) and run with "python2 gtk_sample.py":

# example gtk program
import pygtk
pygtk.require('2.0')
import gtk

class gtk_sample:
  def callback(self, widget, data):
    print("Hello again - %s was pressed" % data)

  def delete_event(self, widget, event, data=None):
    gtk.main_quit()
    return False

  def __init__(self):
    self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    self.window.set_title("gtk example")
    self.window.connect("delete_event", self.delete_event)
    self.window.set_border_width(50)
    self.box1 = gtk.HBox(False, 0)
    self.window.add(self.box1)

    self.button1 = gtk.Button("Yes")
    self.button1.connect("clicked", self.callback, "yes")
    self.box1.pack_start(self.button1, True, True, 0)
    self.button1.show()

    self.button2 = gtk.Button("No")
    self.button2.connect("clicked", self.delete_event, "no")
    self.box1.pack_start(self.button2, True, True, 0)
    self.button2.show()

    self.box1.show()

    self.window.show()

def main():
  gtk.main()
if __name__ == '__main__':
  sample = gtk_sample()
  main()


5.15.2013

I returned to work today since it is the first week of summer break for me. I will normally be in the lab and working on MouseTrap from 1-5pm on Wednesdays and Fridays.

Today I fixed the Ubuntu machine (as per Amber's and Logan's suggestions from a week ago, THANKS AGAIN!) and was able to get past the weird gi.repository issue, though I have an inkling on how to fix it on the Fedora too, I just haven't explored that yet. I was able to debug the code I rewrote from the original source code for the GUI and it doesn't break... but it also doesn't show me an interface.

I moved on to completely writing my own version of the ui.main file and have an interface that shows up with 3 buttons! I am now looking through the ui.settings_gui file and trying to debug that show it shows up when I run my file.

6.12.2013

Sorry I haven't updated in a while, I've been head over heels busy.... Anyways, I have been working on trying to get the GUI interface working with GTK 3 based code. I started to re-code the top main.py in the app/ directory and will be continuing to debug it on Friday. Today I am working on looking through other files in the app/ directory and rewriting them to be GTK 3 friendly.
Personal tools
Namespaces
Variants
Actions
Events
Learning Resources
HFOSS Projects
Evaluation
Navigation
Toolbox