HDRI Community
Picturenaut >> Developer Zone >> Need help: Loading up my own tonemapping dll

Message started by srinathh on 01/16/10 at 11:12:41

Title: Need help: Loading up my own tonemapping dll
Post by srinathh on 01/16/10 at 11:12:41

I have Been taking the sdk for a spin. The Exposure tonemap example compiles & works perfectly and I've been able to replace the tonemapping code in MExpTmo::onTonemap with other code that works in Picturenaut. Cool!

Question 1:
I've been running into problems in getting a dll file of my own to work with picturenaut. I started out by modifying the MExpTmo project, class & filenames & project properties to generate a different dll file.

However, it simply doesn't show up in Picturenaut Tonemapper's list. To trace what's happening, I added a bunch of printfs that show the function names in the plugin-class functions & captured what it wrote to STDOUT by re-directing to a text file

Here's the output i got in the sequence of functions as my DLL file loaded up in Picturenaut-

Code (]
in getPlugInName
Trying to initPlugin
in constructor of tmofactory
Looks ok- tmofactory built
In getTonemapFactoryHandle
In getTonemapClassName
In getTonemapClassName

So the dll seems to seems to run ok till it encoutners getTonemapClassName

Now - looking @ the example MExpTmo code - here's this function returns as the tonemap class name "pn::PNExpTMO".  I couldn't find this function name referred to anywhere else in the code :-(

so what is the function & what should go in here in a customized tonemap dll? My guess is this is where i'm getting stuck.

Here's the full function -
MExpTmoPlugIn::getTonemapClassName() const {
  return pn_text("pn::PNExpTmo");
} // MExpTmoPlugIn::getPlugInName

Question 2:
In the plugin code, I found a static global tonemapping plugin object called expTmoPlugIn getting created that doesn't seem to be referred to anywhere else in the code.
Could you tell me what role does this object play & could it be related in any way to not being able to load a different dll? Here's the code...

Code (]
static MExpTmoPlugIn expTmoPlugIn;

Question 3:
In the poster, it's mentioned that "unless specified" picturenaut serves imagebuffers in tiles to enable multithreaded operation. Is there a way to turn this off & get the full image at a go?

Potential addition to Documentation
While compiling my dll, i found that the MExpTmo by default has the exported functions at these ordinals while mine didn't for some reason.

Specifying it in the def file like this seemed to solve the problem of having the functions at the right ordinals.
  getPlugInHandles @1
  getPlugInClass @3
  getPlugInVersion @2

Tonemap dialog feature request:
It would be great to have a way for a tonemap plugin to specify default settings for things like "Automatic lum", "Automatic contrast" and "Gamma" that work best for the plugin. This would give a good "initial" picture to the user who could change it as he wants. I've seen this affect the "initial" picture from some of the existing plugins as well


Title: Re: Need help: Loading up my own tonemapping dll
Post by srinathh on 01/16/10 at 11:16:15
sorry - the forum software seems to be changing "colon P" to a smiley - where ever there's a tounge sticking out smiley in the code - it's "colon P"


Title: Re: Need help: Loading up my own tonemapping dll
Post by Blochi on 01/19/10 at 08:57:19
Only Marc can give you the answer, but if you use the forum's code tag it will not smilify anything. That's the # symbol in the posting toolbar.

Title: Re: Need help: Loading up my own tonemapping dll
Post by srinathh on 01/19/10 at 11:23:33
Thanks for the tip! Cleaned up my question :-)

I also found there's a small check box which says "Check this if you'll be adding code (or don't like smilies)." - checking it also seems to prevent the forum software from adding smileys

Title: Figured out answer to Question 3
Post by srinathh on 01/20/10 at 06:57:39

Have figured out the answer to question 3 - on how to serve the full image as a go to the tonemapper rather than as Tiles.

Essentially we need to over-ride the SetupActionPipeline function in the Tonemapper class and make it specify the dimensions of the whole image as size of the tile.

Here's the code in case anyone needs it -

Code (]

bool MExpTmo::setupActionPipeline(pn::PNActionPipeline &actionPipeline,
int imageIndex,
pn::PPNImageBuffer pInputImage,
pn::PPNImageBuffer pOutputImage,
void *pUserParam,
pn_pcchar pGroupName,
pn::PFNACTION finalAction) {
int options = pOutputImage ? pn::AEO_DEFAULT :pn::AEO_PROVIDE_OUTPUT_BUFFER;
  pn::PNImageBufferList images;

  images.resize(pOutputImage ? 2 : 1);

= *pInputImage;
  if (pOutputImage) {
    images[1] = *pOutputImage;
  } // if

  pnt::_PNSIZE pTileSize;

  pTileSize.cx = pInputImage->getWidth();
  pTileSize.cy = pInputImage->getHeight();

  actionPipeline.addDrawingAction(images, finalAction,
                                  pUserParam, pGroupName,
  return true;
} // PNTonemap::setupActionPipeline

Wonder if there's a way to do this on the fly - ie a slider in the tonemap dialog that can vary tile size & overlap in realtime :-)


Title: Re: Need help: Loading up my own tonemapping dll
Post by Blochi on 01/20/10 at 08:40:54
Well, but for a local tonmapper you should definitely consider the tiles on the opposite left/right edge. That way a seamless 360 panorama can stay seamless.

I'm glad you're hacking away. Looks like you intimidated Marc with that list of questions. ;)

Title: Re: Need help: Loading up my own tonemapping dll
Post by Marc on 01/24/10 at 14:07:14
Hi srinathh,

thank you for using the Picturenaut SDK.

I'll try to answer all your questions.

1. The class name, for example 'PNExpTMO', is a unique name for a tonemap plug-in. If you build your own plug-in, you must specify a different name. Thats all.

I'll explain later in the SDK documentation the backgrounds.

2. Look in the file 'pnplugin.cpp' and the the 171 of the CTOR. All plug-ins are derived from 'PNPlugIn'. The CTOR connects 'this' to a list of plug-in instances. A plug-in list is local for one DLL. You can also see that it is possible to create multiple plug-ins for one DLL.

3. Yes, you can do it in this way ;)
But remember that the multi-core support is practically turned off when the whole image is given as a tile. In addition, support for large images is also disabled. Unless you have a 64-bit version of Picturenaut. But the 64-bit version is not yet there.

I hope I could help a little.


Title: Re: Need help: Loading up my own tonemapping dll
Post by davidb on 12/09/10 at 21:21:24
I thought I would hijack this thread rather than start a new one, as it already contains some of the information I'm after :)

I started playing with the tone mapping example last week.

What I am thinking of doing is porting a version of my bilateral filter/contrast enhancement algorithm to picturenaut.  This takes HDR tiles as input and produces HDR output. 

I'm not interested in tone mapping as such, as the output of the contrast enhancement process is passed to a global TM algorithm and you already have the main ones covered.  You get more flexibility by just doing the contrast step.

I guess my question is which class do I derive from?  The output of tone mapping plugins seem to be normalised after processing*, but I haven't found where yet.

Any tips, or maybe a general purpose filter example?

*determined by passing out some absurd values and seeing what happened.

Title: Re: Need help: Loading up my own tonemapping dll
Post by Marc on 12/09/10 at 23:09:06
You must derive from StandardPlugIn. Then the method 'getPlugInTypeName' must return the string "tonemap" or "filter". Sorry that I haven't any example code for now. The reason is that the actual SDK is too new to bring out many examples that do not work any more in the next SDK version.

For the comming SDK several things have changed. In particular the names of the classes have changed. They don't have any prefixes and there is only one namespace 'pnsdk'. Unicode 16 support was discarded. Because it's a Windows (tm) relict and has a lot of disadvantages I don't want list them all. The new SDK only supports UTF-8 because it is most flexible and most portable. To port existing code to the new SDK, it usually takes only a global name change for the SDK classes. And with the new SDK, there will be more examples.

Title: Re: Need help: Loading up my own tonemapping dll
Post by davidb on 12/10/10 at 08:43:17
How close is the new SDK?  Would it be better for me to wait?

HDRI Community » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2018. All Rights Reserved.