Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Lr SDK: Get people data and face location for cropping?

New Here ,
Aug 27, 2023 Aug 27, 2023

Is there a way to get the face data and location of each image using the Lightroom SDK.

I would like to have a plugin to click one button, tell Lr to find face (dont know how with sdk) in the photos and then use that face location (how to access this in sdk) then use this location to crop every image so that the head size is the same (for school portraits).

 

I see nothing in the sdk on how to trigger find faces or access the face location data. Anyone have any idea?

I saw a post that this info is in the xmp sidecar file (maybe a workaround), but to use that I have to manually tell Lr to create the xmps for the files. I cannot find a way to trigger the sidecar xmp creation using the sdk.

TOPICS
SDK
825
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 27, 2023 Aug 27, 2023

"I saw a post that this info is in the xmp sidecar file ( I cannot find a way to trigger the sidecar xmp creation using the sdk."

 

Use the undocumented method photo:saveMetadata().  Or set the option Catalog Settings > Metadata > Automatically Write Changes Into XMP.

 

Then you can use Exiftool to read the face data from the XMP stored in the raw file's .xmp sidecar or in the XMP metadata stored directly in non-raws.

 

* * *

 

Alternatively, the plugin can use the "sqlite3" utility to read directly from the catalog database file. If you're experienced working with SQL databases, it's not hard to grovel around in the database to find the relevant tables. If you go that route, use the "-readonly" argument to "sqlite3" to ensure that it doesn't delete the transaction log files when it exits.

 

My Any Filter plugin goes this route to access the face data. It's much faster, but it's likely more fragile than reading the file XMP data, since the former is subject to change by Adobe at any time, whereas the latter must conform to industry standards.

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 28, 2023 Aug 28, 2023

Thanks for the suggestion. I really wish some of those undocumented methods were documented somewhere! Took me forver to learn how to set the crop of a image, It is not documented anywhere I can find.

I figured out how to get the face loction data from sqlite3 to a csv file.
If I am processing lots for files would you suggest running 1 query to a csv for each photo or running one big query with a csv output for all the photos I need? Just not sure of how much the overhead would be for every file, and it seems like you have used it before.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 28, 2023 Aug 28, 2023

"I really wish some of those undocumented methods were documented somewhere!"

 

Most aspects of develops settings are undocumented -- Adobe has never removed this warning from the SDK API documentation for photo:getDevelopSettings(): "The develop settings APIs are considered experimental. You should not depend on the contents of the settings table remaining compatible in future versions of Lightroom. The definitive list is the one shown in the UI."

 

I wrote a post last summer about how crops are represented:

https://community.adobe.com/t5/lightroom-classic-discussions/sdk-computing-the-corners-of-a-crop-rec...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 28, 2023 Aug 28, 2023

Is there a undocumented way to tigger Lightroom to find faces on the selected photos, or would I have to do this manualy using the people section?

 

Thanks for that crop post. I missed had to figure out alot of that.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 28, 2023 Aug 28, 2023
LATEST

I don't know of any way for a plugin to trigger finding faces, other than stuffing menu commands and keystrokes with Autohotkey (Windows) and Applescript (Mac), which can be fragile.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 28, 2023 Aug 28, 2023

On my fast Macbook Pro Apple M2 Max, it takes about 0.18 seconds for my plugin to invoke "sqlite3" on one photo to return the face data in a CSV, 0.19 seconds on 640 photos. So there's a definite advantage to minimizing the number of invocations of "sqlite3".

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines