POV-Ray : Newsgroups : povray.programming : Povray output depthmap Server Time
29 Mar 2024 03:28:56 EDT (-0400)
  Povray output depthmap (Message 1 to 1 of 1)  
From: Gottfried Graber
Subject: Povray output depthmap
Date: 4 Dec 2013 09:53:20
Message: <529f41e0$1@news.povray.org>
Hi,

I'm trying to use POVRay to generate test data for computer vision 
algorithms and among other things I need the depth information of the 
scene. With MegaPOV there was a function which lets you do it, but 
MegaPOV won't work with POVRay 3.7 and I would prefer to use the 3.7 
generation because of the multicore support.

I already hacked up the code so I can ouput depthmap and camera 
parameters, but I'm missing the "integration" (using commandline 
switches, determining automatic filenames for animations etc.) I find it 
quite hard to understand the "big picture" in terms of architecture, who 
sends which messages, who receives them, where is certain data 
located/computed (like filenames) so it would be nice if somebody could 
help me out.

I guess having depthmaps is interesting for other people too, so a 
commandline parameter / config file option that outputs depth along with 
the image would be a nice addition to POVRay.

Right now I have the following:

An additional image_depth in ViewData (frontend/renderfrontend.h)

The imge_depth is initialized in RenderFrontend::CreateView() inside the 
if(obj.TryGetBool(kPOVAttrib_OutputToFile, true)) condition.

I changed the TracePixel::operator() so that it returns depth 
information and in TraceTask::SimpleSamplingM0() i create a 
vector<Colour> pixelsDepth where the depth is stored (in the red channel 
of the colour)

I call GetViewData()->CompletedRectangle(rect, serial, pixelsDepth, 1, 
finalTrace) which creates additional messages for the frontend.

In the ImageMessageHandler::DrawPixelBlockSet() the depth information is 
written to vd.image_depth

Then I make an additional call to
vhi->second.render.HandleMessage(sceneData, vhi->second.data, ident, msg)
in RenderFrontend::HandleRenderMessage() inside the
if(ident == kPOVMsgIdent_Done) block, i.e. when the image is finished.

In RenderMessageHandler::HandleMessage() I have an additional
case kPOVMsgIdent_Done and there I write the image_depth data to disk, I 
use a static filename since I couldn't figure out how to access the 
outputfilename.

Also I have code in Scene::SendDoneMessage() to write camera parameters 
to disk.

It would be nice if somebody could help me integrating this stuff into 
the POVRay system architecture.

cheers


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.