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

Adding camera profile correction to dng_validate.exe

Community Beginner ,
Jun 01, 2017 Jun 01, 2017

Copy link to clipboard

Copied

Using Lightroom I know how to apply a camera profile (*.dcp file) to my *.DNG image.

I would like to do the same in an application which I'm writing, so I guess a good

starting point would be to append this functionality to the dng_validate.exe

application.

So I started to add:

    #include "dng_camera_profile.h"

Then added:

    static dng_string gDumpDCP;

And add the following to the error print:

    "-dcp <file>   Load camera profile from <file>.dcp\"\n"

Then I added the function to read the dcp from cli:

else if (option.Matches("dcp", true))

            {

                gDumpDCP.Clear();

                if (index + 1 < argc)

                {

                    gDumpDCP.Set(argv[++index]);

                }

                if (gDumpDCP.IsEmpty() || gDumpDCP.StartsWith("-"))

                {

                    fprintf(stderr, "*** Missing file name after -dcp\n");

                    return 1;

                }

                if (!gDumpDCP.EndsWith(".dcp"))

                {

                    gDumpDCP.Append(".dcp");

                }

            }

Then I load the profile from disk:

     if (gDumpTIF.NotEmpty ())

            {

                dng_camera_profile profile;

                if (gDumpDCP.NotEmpty())

                {

                    dng_file_stream inStream(gDumpDCP.Get());

                    profile.ParseExtended(inStream);

                }

                // Render final image.

                .... rest of code as it was

So how do I now use the profile data to correct the render and write the corrected image?

Views

784

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Beginner , Jun 08, 2017 Jun 08, 2017

So after playing around for a couple of days, I now found the solution. Actually the negative can have multiple camera profiles. So with negative->AddProfile(profile) you just add one. But this won't be used if it's not the first profile! So we first need to clean the profiles and than add one.

AutoPtr<dng_camera_profile> profile(new dng_camera_profile); 
if (gDumpDCP.NotEmpty())
{
     negative->ClearProfiles();
     dng_file_stream inStream(gDumpDCP.Get());
     profile->ParseExtended(inStream);
...

Votes

Translate

Translate
New Here ,
Jun 06, 2017 Jun 06, 2017

Copy link to clipboard

Copied

Can't help yet, but I'm just starting up with the DNG SDK and will be using it extensively in weeks to come. Stay tuned. I'm lucky SOMEONE else is on this forum as recently as 5 days ago. This whole thing is a struggle and I will happily share whatever I find out to help you!

Votes

Translate

Translate

Report

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
Community Beginner ,
Jun 08, 2017 Jun 08, 2017

Copy link to clipboard

Copied

LATEST

So after playing around for a couple of days, I now found the solution. Actually the negative can have multiple camera profiles. So with negative->AddProfile(profile) you just add one. But this won't be used if it's not the first profile! So we first need to clean the profiles and than add one.

AutoPtr<dng_camera_profile> profile(new dng_camera_profile); 
if (gDumpDCP.NotEmpty())
{
     negative->ClearProfiles();
     dng_file_stream inStream(gDumpDCP.Get());
     profile->ParseExtended(inStream); 
     profile->SetWasReadFromDNG();
     negative->AddProfile(profile); 
     printf("Profile count: \"%d\"\n", negative->ProfileCount()); // will be 1 now!
}

Next thing to get the image correctly is to have correct white balance. This can be done in camera or afterwards. For my application with 4 different cameras, the result was the best when using afterward white balance correction. So I found 4 (Temperature,Tint) pairs using Lightroom.

The question was how to add these values in the dng_validate.exe program. I did it like this:

#include "dng_temperature.h"

if (gTemp != NULL && gTint != NULL) 
{
     dng_temperature temperature(gTemp, gTint);
     render.SetWhiteXY(temperature.Get_xy_coord());
}

The resulting images are slightly different from the Lightroom result, but close enough. Also the camera to camera differences are gone now!

Votes

Translate

Translate

Report

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