category formula : find exactly 2 persons

Started by peterverm, July 23, 2018, 08:47:24 PM

Previous topic - Next topic

peterverm

At the highest level, I have "@All|who ?", "@All|what ?" and "@All|where ?" categories.  All are detailed with child categories.

If i want to find all pictures with exact 1 given person on it, and no other persons, i use "@CatDistinct[@All\|who \?\|we\|Peter Vermeyen;@All\|who \?\|we]".  It works fine.  The "@All|what ?" and "@All|where ?" categories are ignored as it should.

But I want to find all pictures with exact 2 persons on it, Ann and Peter, and no other persons.  I tried "@CatDistinct[@All\|who \?|we\|(Ann Verhetsel|Peter Vermeyen);@All\|who \?\|we]".  It gives error.

I thought it would work because it is a regular expression.  But no.

Can someone help me ?

Thanks,

Peter Vermeyen

Mario

Use the AND operator. It allows you to do things like "Cat A" AND "Cat B". There is also OR and NOT. And ( and )

See https://www.photools.com/help/imatch/#cat_formulas.htm?dl=h-4
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

peterverm

I tried AND (before i wrote the post !) : "@CatDistinct[@All\|wie \?|wij\|Ann Verhetsel;@All\|wie \?\|wij]" AND "@CatDistinct[@All\|wie \?|wij\|Peter Vermeyen;@All\|wie \?\|wij]"

It does not work, you cannot have a picture with 1 distinct person A and 1 distinct person B, because there would be 2 distinct persons.

OR works of course, but then i get all the pictures with only A plus all the pictures with only B.

What i need is something like 'contains A' AND 'contains B' AND 'total number of persons = 2'.

Regards,

Peter

Mario

#3
"Mary" AND "Peter" returns all files which have both categories applied. There may be other persons also shown in these images. Since IMatch has no information about how many persons or other objects are contained in your image, it is impossible to achieve what you want.

You need to setup a category hierarchy which counts the number of persons per image. Do you use face annotations? Then maybe a data-driven category based on the corresponding collection will do that automatically...you can then include these categories in your formula to limit something like "Mary" and "Peter" AND "PersonCount.2".

If you work with @Keywords categories, you can setup a data-driven category which is based on the keyword count, with a regexp to consider only persons. This could also produce a category which counts the number of persons per image. I did not try this, just an idea.

Another idea would be something like a new category formula which counts how many categories inside a specific hierarchy level are assigned to a file...but that would require a feature request and probably not easy to implement and critical performance-wise.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

mastodon

That is challenge for me, too. I think I will make categories like alone, pair, threesome etc. and group. But I will set only that pictures in that categories that are really useful for that purpose and not just "mention" these persons.

PaulS

Quote from: Mario on July 23, 2018, 09:48:44 PM
Another idea would be something like a new category formula which counts how many categories inside a specific hierarchy level are assigned to a file...but that would require a feature request and probably not easy to implement and critical performance-wise.

Actually this is already implemented and works quite well for me.  Especially with the enhancement for IMatch 2018 (Thanks Mario!) that allows Alias categories to be excluded.  In my case, the formula is:

    {File.Categories.DirectNoAlias|filter:^Subject\|People;count:true}

If I guess correctly, in Peter's case it might be:

    {File.Categories.DirectNoAlias|filter:^who \?;count:true}

Use the VarToy app to confirm proper variable definition. 

I've attached a screen shot of my setup and the resulting category.  I used the Replace Mask to add a leading 0 to force sort order of the categories.  Make sure that Automatic Update is Off or you will have a performance hit as Mario said, and then manually Refresh Data from time to time to keep the category updated.

You can then create a Formula category with the desired number category AND the desired people categories.

Alternatively, you can just select the desired number category and use the Filter Panel to select the desired people using AND.  (By the way, I just found that I have only 18 pictures of just my wife and me out of 28,413 ::))

Mario

This is a good way to do it. Thank you for sharing.

For details, search for DirectNoAlias in this help topic: https://www.photools.com/help/imatch/#var_basics.htm

It seems a bit complicated, but tasks like "Crete a category with files showing only these two persons but no other" are complicated by nature. Unless you maintain a separate "People Count" category hierarchy or a "Single/Pair/Three/Group/Larger Group" hierarchy some users maintain. In that case you can directly use that in your category formula.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

axel.hennig

There was a very similar post about this problem (and I think the solution is very good):

https://www.photools.com/community/index.php?topic=7403.msg51484

@Peter Vermeyen: Maybe this helps.

peterverm

OK thank you all, your feedback will get me going.  Peter

peterverm

Dears,

your solution works fine, thanks, only, there is something strange.

{File.Categories|filter:^wie \?;count:true} works fine.

{File.Categories.Direct|filter:^wie \?;count:true} works fine.

{File.Categories.DirectNoAlias|filter:^wie \?;count:true} does not work.  All files end up in "Other".  I do not use Alias categories.  So this is strange.  Can you explain it ?

Regards,

Peter

Mario

Export your categories and attach a ZIP.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

peterverm


Mario

I've imported your categories and then assigned images to child categories of "wie ?"

I assigned one set of files to one category, and a second set to another category.
A 3rd set was assigned to two categories below "wie ?"

I then used your variables in the VarToy app to see what they return, like this:

{File.Categories|filter:^wie \?;count:true}
{File.Categories.Direct|filter:^wie \?;count:true}
{File.Categories.DirectNoAlias|filter:^wie \?;count:true}


as expected, all variables returned the same result for all files (1 or 2).
Then I created an Alias category named "ALIAS familie Ann" under "wie ?", aliasing "familie Ann".
Now the results of  DirectNoAlias and Direct differ. Direct shows a count of 2 for the files in the Alias category, DirectNoAlias shows 1.  Correct.

I've tried both variables in a data-driven category and the results are correct.
The only way to produce a result which has only "Other" is an invalid variable, as far as I can tel. Did you check for syntax errors?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

peterverm

Mario,

thanks for your efforts. 

I tried the 3 variables with the VarToy.

For all pictures that i tried,
- {File.Categories|filter:^wie \?;count:true} and {File.Categories.Direct|filter:^wie \?;count:true} give a result, but
- {File.Categories.DirectNoAlias|filter:^wie \?;count:true} gives never a result.

See print screen in attachment.

Regards,

Peter

sinus

Peter,
Do you have really any alias-categories?
Best wishes from Switzerland! :-)
Markus

peterverm

Thanks for the wishes.  Enjoy Switserland.

No i do not have an Alias category. 

I just created one as a test, i see no difference in the behavior : {File.Categories.DirectNoAlias|filter:^wie \?;count:true} returns "other".

Regards,

Peter

Mario

Did you copy/paste my variable setup from above?
It produces correct results for all my databases.

What happens if you change the expression for NoAlias, e.g. to include the entire DB?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

#17
And a remark:

This variable (from the help):

{File.Categories.DirectNoAlias|filter:^People;count:true}

gives me the number 1, what is wrong.

This variable:
{File.Categories.DirectNoAlias|filter:^People|;count:true}

gives me the number 5, what is correct.

The difference is the symbol | after the Category.


But I am not sure with all this stuff here.  :-[
Best wishes from Switzerland! :-)
Markus

Mario

The | has a special meaning in regular expressions. If you want to use a literal | you need to escape it with \ => \|
If the result is wrong is impossible to know unless we know your category structure.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

peterverm

@Mario : not sure what you mean, but this is what i did : i copy/paste the variables from your reply, i removed filter, and next i removed count as well.

1. {File.Categories}
2. {File.Categories.Direct}
3. {File.Categories.DirectNoAlias}
xxx
4. {File.Categories|count:true}
5. {File.Categories.Direct|count:true}
6. {File.Categories.DirectNoAlias|count:true}
xxx

Same result as before : cases 3. and 6. give no result.  See print screen.  So it has nothing to do with filter or count.

@sinus : the symbol | after the Category makes no difference, even if i escape it \|.

Mario

This is what I get (IMatch 2018.7.4):

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

PaulS

Hello Peter,

Just a wild guess. I changed the variable to something which is undefined as shown below and get the result you describe of all files in Other.

    File.Categories.DirectYesAlias

By any chance are you still using IMatch 2017?  File.Categories.DirectNoAlias was added in IMatch 2018, it is undefined in IMatch 2017 and I expect it would give the result you describe.

Paul









Mario

Good point!

I never saw a log file for this issue so I don't know either. As you said, the ...Alias formula is available in IMatch 2018 only.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

peterverm

OK, victory !  I was 2017.14.2, i upgraded to 2018.7.4, and File.Categories.DirectNoAlias works fine.

Thanks,

Peter

Mario

Since you don't use Alias categories, the File.Categories.Direct would do the trick.
Thanks for upgrading!  :) You are actively supporting IMatch and I hope you enjoy using it.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook