After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 737612 - MouseTrap core dumps upon startup with Python 3 and OpenCV3
MouseTrap core dumps upon startup with Python 3 and OpenCV3
Status: RESOLVED FIXED
Product: mousetrap
Classification: Other
Component: General
unspecified
Other Linux
: Normal blocker
: ---
Assigned To: mousetrap-maint
mousetrap-maint
Depends on:
Blocks:
 
 
Reported: 2014-09-29 17:52 UTC by Heidi Ellis
Modified: 2015-02-23 22:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Output when running MouseTrap on the command line (1.06 KB, text/plain)
2014-10-28 03:07 UTC, Kevin Brown
Details
GDB Backtrace from running MouseTrap when it core dumps (2.23 KB, text/plain)
2014-10-28 03:07 UTC, Kevin Brown
Details

Description Heidi Ellis 2014-09-29 17:52:23 UTC
System:  Fedora 20

MouseTrap works as expected when run with Python2 and OpenCV2. However, when executing MouseTrap with Python3 and OpenCV3, it core dumps before showing the user's image.
Comment 1 Trevor Breton 2014-10-01 23:32:38 UTC
System: Fedora 20

While working on the CS Lab computer, after installation of Python3 and OpenCV3, I also experience this issue. On 1 ocassion out of the 4 tries, the user's image popped up for a fraction of a second and then was dumped. On the other three, nothing happened before the core dumped.
Comment 2 Fulya 2014-10-02 00:15:32 UTC
System: Fedora 20 

I got the same error where MouseTrap gives a core dump, after executing MouseTrap with Python3 and OpenCV3. This happened right after the camera detected a person in view. MouseTrap ran fine while there were no people in sight.
Comment 3 Andrew 2014-10-02 01:17:43 UTC
As previous students have already mentioned, I too have experienced this fatal error.  On my own personal machine, the light on my webcam showing that it was active, turned on right after executing the mousetrap program and the immediately went out as the core dump message occurred on the terminal.  The exact error seemed to be:

2014-10-01 21:11:38,111 - mousetrap.core - INFO - Initializing
VIDEOIO ERROR: V4L/V4L2: VIDIOC_S_CROP
VIDEOIO ERROR: V4L/V4L2: VIDIOC_S_CROP


This error would only occur when mousetrap detected a face. While standing away from the computer, I executed mousetrap and it ran fine up until I stepped back into view of the webcam and mousetrap detected my face.
Comment 4 Andrew 2014-10-02 01:20:35 UTC
My mistake the exact point of the core dump was at:

2014-10-01 21:16:20,378 - mousetrap.vision - INFO - Feature detected: face
Segmentation fault (core dumped)
 
not the error I had posted before.
Comment 5 Elise 2014-10-02 01:31:42 UTC
MouseTrap seems to initialize properly and for me produced the camera view
window. The core dump could possibly occur after the face is detected (in the
vision.py file where the "Feature detected: face" prints), but when it tries to track the head's movements, that's when the core dumped occurs. I found that if I stayed still, MouseTrap would continue running, but when I moved my head the "Segmentation fault (core dumped)" occurred.
Comment 6 Alexander 2014-10-02 22:54:42 UTC
System: Ubuntu 14.04

Similar to the previously reported errors, a core dump occurred as soon as a users face was detected. I tried running MouseTrap without a person in the image and it opened properly and displayed the image. But as soon as I moved my head into the view of the camera it would cause a core dump. I would think that the core dump is being caused in one of the face detection methods. 

Using Python 3 and OpenCV 3.
Comment 7 Kevin Brown 2014-10-28 03:07:03 UTC
Created attachment 289492 [details]
Output when running MouseTrap on the command line
Comment 8 Kevin Brown 2014-10-28 03:07:40 UTC
Created attachment 289493 [details]
GDB Backtrace from running MouseTrap when it core dumps
Comment 9 Kevin Brown 2014-10-28 03:09:06 UTC
I believe the error happens while trying to detect the nose, which is the next object to detect after the face. This appears to be an issue within OpenCV, and does not appear to be an issue isolated to the Python bindings.

I have attached the program output from mousetrap when it is run from the command line [3]. This points to the error happening after the face is detected, which explains why MouseTrap does not fail if the face is not detected (such as when the camera is covered). The core dump occurs when trying to detect the nose based on the image of the face [1].

I've also included the gdb backtrace for the core dump, which seems to point to an internal function causing the core dump [4]. Unfortunately I was not able to compile OpenCV 3 with the Python debugging headers, or I would have attached gdb output that included them.

When I did some research into the issue over the weekend, I discovered an issue in OpenCV when resizing images [2]. I believe when we are searching for the nose, we need to resize the image (to only include the face) before it is passed to the nose detector, so this may be where we are running into issues. If we can test and verify that MouseTrap works without resizing the image to only include the face, we may be able to better narrow down the issue.

[1]: https://git.gnome.org/browse/mousetrap/tree/src/mousetrap/vision.py?h=gnome3-wip#n165
[2]: http://code.opencv.org/issues/3311
[3]: https://bugzilla.gnome.org/attachment.cgi?id=289492
[4]: https://bugzilla.gnome.org/attachment.cgi?id=289493
Comment 10 Kevin Brown 2014-10-30 20:37:34 UTC
I did some more testing earlier today and determined that the core dump is not because we are resizing the image, and the problem does not affect the face locator. If the nose locator is swapped out with the face locator, the code continues to run without failing, but if the nose locator is called (at all), the program ends with the original core dump.

This leads me to believe that the haar cascades used for detecting the nose may have problems in OpenCV 3, which will require more testing. The haar cascade does not appear to match the current nose cascade provided by OpenCV [1], so that may be something to check.

Once we can get an isolated test case that verifies the problem, a ticket may need to be created in the OpenCV ticket tracker [2].

[1]: https://github.com/Itseez/opencv_contrib/blob/f8d7711ef572bed2acbae264629f2c8e888376ed/modules/face/data/cascades/haarcascade_mcs_nose.xml
[2]: http://code.opencv.org/projects/OpenCV/wiki/WikiStart#Creating-new-tickets
Comment 11 Stoney Jackson 2015-01-26 21:13:32 UTC
We are going to try to finalize this. We are working here: https://github.com/Mousers/mousetrap/issues/9
Comment 12 Maxwell Lemkin 2015-02-09 04:05:00 UTC
I can not upload the patch because it is too large for Bugzilla, so here is a link to the patch: https://github.com/Mousers/mousetrap/commit/b23fa89fc25563d036871b07736ac59763f6a090.patch
Comment 13 Stoney Jackson 2015-02-11 19:24:46 UTC
Patch was rejected. Although it solves the core dump, it did not solve the larger issue of "getting things working". I.e., this bug report is part of a larger story:

"As a user, I want to be able to run MouseTrap on Python 3 and OpenCV 3."

As such, it's hard to know if any single patch is getting us closer to the goal until we have reached the goal.

Mousers continue to work on this issue. We are working to isolate the problem.
Comment 14 Stoney Jackson 2015-02-23 22:29:29 UTC
Now that master is an unstable, development branch; and now that we have a gnome-3-17 branch for stabilizing; we are now accepting this patch and closing this issue.

Fixing this bug has uncovered a new bug: https://bugzilla.gnome.org/show_bug.cgi?id=745051