[vtkusers] vtkImageData Reflection

Cameron Lowell Palmer cameron.palmer at ntnu.no
Tue Jan 27 05:10:51 EST 2015


OK, so I’m taking your advice and putting things back the way they were.

I spent 45+ minutes trying to figure out how to make vtkImageData reflect using vtkImageFlip. So I gave up and just used the Accelerate Framework in iOS to get the job done which was trivial. Would be nice if someone could give an example that works within the context of VES, because the example I found was making calls into VTK actors and mappers that aren’t available (in an obvious way) to VES.

                void *rawPixelData = malloc(videoFrame.totalBytes);
        vImage_Buffer mirrorImageBuffer;
        mirrorImageBuffer.width = videoFrame.width;
        mirrorImageBuffer.height = videoFrame.height;
        mirrorImageBuffer.rowBytes = videoFrame.bytesPerRow;
        mirrorImageBuffer.data = rawPixelData;
        vImageVerticalReflect_ARGB8888(&rgbaImageBuffer, &mirrorImageBuffer, kvImageDoNotTile);

…

        free(rawPixelData);

My thought was that within the vesKiwiImagePlaneDataRepresentation you could just flip the image in setImageData, but I felt to do it there I would be down to manipulating the shader per usual and I’m loath to do that.

cameron.



On 26. jan. 2015, at 14.53, Cory Quammen <cory.quammen at kitware.com<mailto:cory.quammen at kitware.com>> wrote:

I don't know if that's a supremely bad idea, but it may make life complicated if you want to display anything else besides the image :-)

It might be safest to just flip the image with the vtkImageFlip filter or flip the order of pixels in the incoming image yourself.

On Mon, Jan 26, 2015 at 8:49 AM, Cameron Lowell Palmer <cameron.palmer at ntnu.no<mailto:cameron.palmer at ntnu.no>> wrote:
On a scale of 1 to supremely bad idea, how about flipping the location of the camera and view up?

I did precisely that by making the camera face the positive z-axis, this also required me to flip the Y-Axis by changing the view up. I thought the issue was that the camera facing the negative z-axis and therefore was seeing the backside of the image.

cameron

From: Cory Quammen <cory.quammen at kitware.com<mailto:cory.quammen at kitware.com>>
Date: mandag 26. januar 2015 14.45
To: Cameron Lowell Palmer <cameron.palmer at ntnu.no<mailto:cameron.palmer at ntnu.no>>
Cc: VTK Users <vtkusers at vtk.org<mailto:vtkusers at vtk.org>>
Subject: Re: [vtkusers] vtkImageData Reflection

Cameron,

It looks like your camera's convention for image origin and VTK's disagree. You could correct it in the display by scaling the reversed axis of the actor that displays the image by -1, or you can flip the data after import with a vtkImageFlip filiter.

HTH,
Cory

On Mon, Jan 26, 2015 at 7:29 AM, Cameron Lowell Palmer <cameron.palmer at ntnu.no<mailto:cameron.palmer at ntnu.no>> wrote:
When receiving a camera frame I’m converting to vtkImageData like this:

    auto imageImport = vtkSmartPointer<vtkImageImport>::New();
    imageImport->SetDataSpacing(1.0f, 1.0f, 1.0f);
    imageImport->SetDataOrigin(0.f, 0.f, 0.f);
    imageImport->SetWholeExtent(0.f, videoFrame.width - 1.f, 0.f, videoFrame.height - 1.f, 0.f, 0.f);
    imageImport->SetDataExtentToWholeExtent();
    imageImport->SetDataScalarTypeToUnsignedChar();
    imageImport->SetNumberOfScalarComponents(4);
    imageImport->SetImportVoidPointer(videoFrame.rawPixelData);
    imageImport->Update();

    vtkSmartPointer<vtkImageData> imageData = imageImport->GetOutput();

It works, but adding this to an image plane the image is mirrored across the Y-axis (right-left). Am I doing this image conversion correctly?

cameron

_______________________________________________
Powered by www.kitware.com<http://www.kitware.com/>

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers




--
Cory Quammen
R&D Engineer
Kitware, Inc.



--
Cory Quammen
R&D Engineer
Kitware, Inc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150127/6f46ce7a/attachment.html>


More information about the vtkusers mailing list