Quantcast

Re: [Gramps-devel] Phototagging Gramphlet

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Gramps-devel] Phototagging Gramphlet

Doug-11
On 25/02/17 17:08, Josip wrote:

> 25.2.2017. u 16:19, Paul Culley je napisao/la:
>> A (somewhat related) side question.  If we figure out how to get OpenCV
>> support (keep up the good work Serge), but the Linux distros don't include
>> the appropriate versions, is it possible for us to somehow include a good
>> version with Gramps?
>>
>> I know that we could do this with Josips Windows AIO, since he includes
>> lots of pre-built libraries already, but how could this be done with Gramps
>> For Linux, or MAC?
>>
>> Maybe a script for Linux folks that downloads and installs the appropriate
>> parts from known good locations (maybe even copies from our own Github)?
>>
>> As a barely adequate Linux newbie, I struggle with finding and installing
>> things, I hate to think what less sophisticated users would go through.
> OpenCV is to big and have too many dependencies to be included in any
> package.
> But why it should be included anyway?
> It is used only in phototagging gramplet to detect presence of faces and
> eyes on image (big deal, if you can't see that this is face then how you
> would know is aunt Martha face and tag-git as such ). Unless some expert
> on facial recognition write something useful with OpenCV for us we need
> him as much as we need WebKitGTK in HtmlView gramplet.
That pretty much expresses my need for face detection too.


>
> Real problem with PhotoTagging gramplet is more like
> ReferenceMediaEditor one. It response badly to window resize so region
> selection often not works.
>
Aah! So you have the same sort of problem with phototagging
as me.

Do you see any way round this?

Doug


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gramps-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-users
https://gramps-project.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Gramps-devel] Phototagging Gramphlet

Doug-11
On 25/02/17 18:40, Serge Noiraud wrote:

> Le 25/02/2017 à  14:30, Doug a écrit :
>> On 25/02/17 10:25, Serge Noiraud wrote:
>>> Le 22/02/2017 à 00:56, Renee S a écrit :
>>>> Hi,
>>>> I know python fairly well and I like gramps so I wanted
>>>> to start contributing to it. I wanted to fix the
>>>> phototagging gramphlet but I'm kind of confused about
>>>> what needs to be done to fix it. On the addons status
>>>> page it says this: Age column missing / OpenCV needed
>>>> for facedetection and its gtk3 status and python 3
>>>> status are marked as to do. I don't know what the age
>>>> column is and I also dont know whether or not
>>>> facedetection actually has opencv supported, as I was
>>>> looking at the github and it said the last edit to
>>>> facedetection was "partial update for opencv" But when I
>>>> look at the comparison for before and after the change
>>>> was made every line of code had been edited. Any insight
>>>> on this is greatly appreciated.
>>>> Thanks!
>>> The problem is opencv which doesn't work with python3.
>>> ubuntu and debian don't provides opencv version ftr python3.
>>> I don't know for other distributions.
>>>
>>> I tried to compile opencv 3.2.0.
>>> For this I followed
>>> http://cyaninfinite.com/tutorials/installing-opencv-in-ubuntu-for-python-3/
>>>
>>> It works great for me.
>>> After that, we need to modify facedetection.py and
>>> PhotoTaggingGramplet.py
>>> --- a/facedetection.py    2017-02-23
>>> 13:02:06.787603497 +0100
>>> +++ b/facedetection.py    2017-02-24
>>> 18:30:28.603960198 +0100
>>> @@ -57,12 +57,9 @@
>>>  #-------------------------------------------------------------------------
>>> ÂÂ
>>>  def detect_faces(image_path, min_face_size):
>>> -    cv_image = cv.LoadImage(image_path,
>>> cv.CV_LOAD_IMAGE_GRAYSCALE)
>>> -    o_width, o_height = cv_image.width,
>>> cv_image.height
>>> -    cv.EqualizeHist(cv_image, cv_image)
>>> -    cascade = cv.Load(HAARCASCADE_PATH)
>>> -    faces = cv.HaarDetectObjects(cv_image,
>>> cascade,
>>> -                               ÂÂ
>>> cv.CreateMemStorage(0),
>>> -                               ÂÂ
>>> 1.2, 2, cv.CV_HAAR_DO_CANNY_PRUNING,
>>> -                               ÂÂ
>>> min_face_size)
>>> +    cv_image = cv.imread(image_path,
>>> cv.IMREAD_GRAYSCALE)
>>> +    o_width, o_height = cv_image.shape[:2]
>>> +    cv.equalizeHist(cv_image, cv_image)
>>> +    cascade =
>>> cv.CascadeClassifier(HAARCASCADE_PATH)
>>> +    faces = cascade.detectMultiScale(cv_image,
>>> 1.2, 2)
>>>      return faces
>>> --- a/PhotoTaggingGramplet.py    2017-02-23
>>> 13:02:06.786603508 +0100
>>> +++ b/PhotoTaggingGramplet.py    2017-02-24
>>> 19:20:58.302565809 +0100
>>> @@ -622,7 +622,7 @@
>>> ÂÂ
>>>          # populate the context menu
>>>          persons =
>>> self.all_referenced_persons()
>>> -        if selected.person is not None:
>>> +        if selected is not None and
>>> selected.person is not None:
>>>            ÂÂ
>>> persons.remove(selected.person)
>>>          if persons:
>>>            ÂÂ
>>> self.additional_items.append(Gtk.SeparatorMenuItem())
>>> @@ -725,7 +725,7 @@
>>>          media =
>>> self.get_current_object()
>>>          image_path =
>>> media_path_full(self.dbstate.db, media.get_path())
>>>          faces =
>>> facedetection.detect_faces(image_path, MIN_FACE_SIZE)
>>> -        for ((x, y, width, height),
>>> neighbors) in faces:
>>> +        for (x, y, width, height)
>>> in faces:
>>>              region =
>>> Region(x - DETECTED_REGION_PADDING,
>>>                            ÂÂ
>>> y - DETECTED_REGION_PADDING,
>>>                            ÂÂ
>>> x + width + DETECTED_REGION_PADDING,
>>>
>>> We need to update haarcascade_frontalface_alt.xml to the
>>> new version.
>>> This file is in
>>> opencv-3.2.0/samples/winrt/FaceDetection/FaceDetection/Assets/
>>>
>>> Serge
>>
>> Serge,
>>
>> Which gramps version are you using? I'm on 4.2.5-d1d08a1.
> I use 4.2.6-8c7133a but it should work with 4.2.5
>>
>> I'm wondering if I follow your instructions for updating
>> opencv that should solve the problems I'm seeing or
>> whether they're only relevant to face detection (which I
>> don't use).

> This solves the face detection. I suppose you spoke about
> the age column ? (bug 8121)

No, that wasn't my problem (at least as far as I remember
the age column was present when phototagging was last working).

My problem got merged with #8121, but in fact it was similar
to Josip's:
"It response badly to window resize so region
selection often not works".

Does that work OK for you?


>> Â
>> What about updating haarcascade_frontalface_alt.xml?
> I'm not sure it will works. The files are very differents.
>>
>>
>> Doug
>> Â
>
> Serge
>

I'm probably misunderstanding what haarcascade_frontalface
does - is it needed if face detection is not being used?

Doug

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gramps-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-users
https://gramps-project.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Gramps-devel] Phototagging Gramphlet

Doug-11
On 26/02/17 16:22, Doug wrote:

> On 25/02/17 18:40, Serge Noiraud wrote:
>> Le 25/02/2017 à  14:30, Doug a écrit :
>>> On 25/02/17 10:25, Serge Noiraud wrote:
>>>> Le 22/02/2017 ÃÂ  00:56, Renee S a écritÂÂ :
>>>>> Hi,
>>>>> I know python fairly well and I like gramps so I wanted
>>>>> to start contributing to it. I wanted to fix the
>>>>> phototagging gramphlet but I'm kind of confused about
>>>>> what needs to be done to fix it. On the addons status
>>>>> page it says this: Age column missing / OpenCV needed
>>>>> for facedetection and its gtk3 status and python 3
>>>>> status are marked as to do. I don't know what the age
>>>>> column is and I also dont know whether or not
>>>>> facedetection actually has opencv supported, as I was
>>>>> looking at the github and it said the last edit to
>>>>> facedetection was "partial update for opencv" But when I
>>>>> look at the comparison for before and after the change
>>>>> was made every line of code had been edited. Any insight
>>>>> on this is greatly appreciated.
>>>>> Thanks!
>>>> The problem is opencv which doesn't work with python3.
>>>> ubuntu and debian don't provides opencv version ftr python3.
>>>> I don't know for other distributions.
>>>>
>>>> I tried to compile opencv 3.2.0.
>>>> For this I followed
>>>> http://cyaninfinite.com/tutorials/installing-opencv-in-ubuntu-for-python-3/
>>>>
>>>> It works great for me.
>>>> After that, we need to modify facedetection.py and
>>>> PhotoTaggingGramplet.py
>>>> --- a/facedetection.pyÂÂ ÂÂ ÂÂ  2017-02-23
>>>> 13:02:06.787603497 +0100
>>>> +++ b/facedetection.pyÂÂ ÂÂ ÂÂ  2017-02-24
>>>> 18:30:28.603960198 +0100
>>>> @@ -57,12 +57,9 @@
>>>>  #-------------------------------------------------------------------------
>>>> ÂÂ
>>>>  def detect_faces(image_path, min_face_size):
>>>> -ÂÂ ÂÂ ÂÂ  cv_image = cv.LoadImage(image_path,
>>>> cv.CV_LOAD_IMAGE_GRAYSCALE)
>>>> -ÂÂ ÂÂ ÂÂ  o_width, o_height = cv_image.width,
>>>> cv_image.height
>>>> -ÂÂ ÂÂ ÂÂ  cv.EqualizeHist(cv_image, cv_image)
>>>> -ÂÂ ÂÂ ÂÂ  cascade = cv.Load(HAARCASCADE_PATH)
>>>> -ÂÂ ÂÂ ÂÂ  faces = cv.HaarDetectObjects(cv_image,
>>>> cascade,
>>>> -                               ÂÂ
>>>> cv.CreateMemStorage(0),
>>>> -                               ÂÂ
>>>> 1.2, 2, cv.CV_HAAR_DO_CANNY_PRUNING,
>>>> -                               ÂÂ
>>>> min_face_size)
>>>> +ÂÂ ÂÂ ÂÂ  cv_image = cv.imread(image_path,
>>>> cv.IMREAD_GRAYSCALE)
>>>> +ÂÂ ÂÂ ÂÂ  o_width, o_height = cv_image.shape[:2]
>>>> +ÂÂ ÂÂ ÂÂ  cv.equalizeHist(cv_image, cv_image)
>>>> +ÂÂ ÂÂ ÂÂ  cascade =
>>>> cv.CascadeClassifier(HAARCASCADE_PATH)
>>>> +ÂÂ ÂÂ ÂÂ  faces = cascade.detectMultiScale(cv_image,
>>>> 1.2, 2)
>>>> ÂÂ ÂÂ ÂÂ ÂÂ  return faces
>>>> --- a/PhotoTaggingGramplet.pyÂÂ ÂÂ ÂÂ  2017-02-23
>>>> 13:02:06.786603508 +0100
>>>> +++ b/PhotoTaggingGramplet.pyÂÂ ÂÂ ÂÂ  2017-02-24
>>>> 19:20:58.302565809 +0100
>>>> @@ -622,7 +622,7 @@
>>>> ÂÂ
>>>> ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ  # populate the context menu
>>>> ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ  persons =
>>>> self.all_referenced_persons()
>>>> -ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ  if selected.person is not None:
>>>> +ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ  if selected is not None and
>>>> selected.person is not None:
>>>>            ÂÂ
>>>> persons.remove(selected.person)
>>>> ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ  if persons:
>>>>            ÂÂ
>>>> self.additional_items.append(Gtk.SeparatorMenuItem())
>>>> @@ -725,7 +725,7 @@
>>>> ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ  media =
>>>> self.get_current_object()
>>>> ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ  image_path =
>>>> media_path_full(self.dbstate.db, media.get_path())
>>>> ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ  faces =
>>>> facedetection.detect_faces(image_path, MIN_FACE_SIZE)
>>>> -ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ  for ((x, y, width, height),
>>>> neighbors) in faces:
>>>> +ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ  for (x, y, width, height)
>>>> in faces:
>>>> ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ ÂÂ  region =
>>>> Region(x - DETECTED_REGION_PADDING,
>>>>                            ÂÂ
>>>> y - DETECTED_REGION_PADDING,
>>>>                            ÂÂ
>>>> x + width + DETECTED_REGION_PADDING,
>>>>
>>>> We need to update haarcascade_frontalface_alt.xml to the
>>>> new version.
>>>> This file is in
>>>> opencv-3.2.0/samples/winrt/FaceDetection/FaceDetection/Assets/
>>>>
>>>> Serge
>>> Serge,
>>>
>>> Which gramps version are you using? I'm on 4.2.5-d1d08a1.
>> I use 4.2.6-8c7133a but it should work with 4.2.5
>>> I'm wondering if I follow your instructions for updating
>>> opencv that should solve the problems I'm seeing or
>>> whether they're only relevant to face detection (which I
>>> don't use).
>> This solves the face detection. I suppose you spoke about
>> the age column ? (bug 8121)
> No, that wasn't my problem (at least as far as I remember
> the age column was present when phototagging was last working).
>
> My problem got merged with #8121, but in fact it was similar
> to Josip's:

P.S. Apart from the fact that it now doesn't seem to work at all
<snip>

Doug

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gramps-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-users
https://gramps-project.org
Loading...