Spherical Video PTZ/User Guide/Quick Start Guide: Difference between revisions

Line 44: Line 44:
#include "lp/engines/equirectangular_to_rectilinear.hpp"
#include "lp/engines/equirectangular_to_rectilinear.hpp"


engines::EquirectangularToRectilinear<RGBA<uint8_t>> engine;
lp::engines::EquirectangularToRectilinear<RGBA<uint8_t>> engine;
</syntaxhighlight>
</syntaxhighlight>


Then, set the initial parameters with the '''SetParameters''' method:
Then, set the initial parameters with the '''SetParameters''' method:
<syntaxhighlight lang=cpp>
<syntaxhighlight lang=cpp>
engine.SetParameters(params);
lp::engine.SetParameters(params);
</syntaxhighlight>
</syntaxhighlight>


Finally process the input image with the '''Process''' method:
 
Finally, use the '''Process''' method with the input image as the first parameter. The second parameter will contain the result after applying the equirectangular to rectilinear projection transformation.
<syntaxhighlight lang=cpp>
<syntaxhighlight lang=cpp>
#include "lp/allocators/cudaimage.hpp"
#include "lp/allocators/cudaimage.hpp"
Line 60: Line 62:
lp::allocators::CudaImage<RGBA<uint8_t>> dst;
lp::allocators::CudaImage<RGBA<uint8_t>> dst;


engine.Process(img, dst);
lp::engine.Process(img, dst);
</syntaxhighlight>
</syntaxhighlight>


Please note that the Engine supports both '''CudaImages''' and '''Images''' for processing. However, if you choose to use an Image, the Engine will internally allocate a Cuda buffer and copy the Image content into it, potentially affecting the application performance.
 
Please note that the Engine supports both '''CudaImages''' and '''Images''' for processing. However, if you choose to use an Image, the Engine will internally allocate a Cuda buffer and copy the Image content into it, potentially affecting the application performance. Take this pseudo-code snippet as an loop example of the engine's usage:
 
<syntaxhighlight lang=cpp>
#include "lp/image.hpp"
 
int main(int argc, char **argv) {
  ImageSize size{500, 500};                                    /* size of the output image */
  const size_t rawsize = size.PixelCount();
 
  OpenCV<RGBA<uint8_t>> io.Open(image_path);
  Image<RGBA<uint8_t>> img = io.ReadImage();
  lp::Image<RGBA<uint8_t>> dst =
      Image(size, std::shared_ptr<RGBA<uint8_t>[]>(new RGBA<uint8_t>[rawsize]));
 
  engines::EquirectangularToRectilinear<RGBA<uint8_t>> engine;
  engines::EquirectangularToRectilinearParams params{{
                                                      {0.0f, 0.0f},
                                                      2.0f,
                                                    },
                                                    {
                                                      dst.GetSize(),
                                                    },
                                                    {io.GetSize()}};
 
  engine.SetParameters(params);
  engine.Process(img, dst);
 
  for (int i = 1; i <= 100; i++) {
    params.equirectangular.r -= 0.05;                          /* zoom out */
    params.equirectangular.viewpoint + Point2D{0.05f, 0.00f};  /* tilt right */
    params.equirectangular.viewpoint + Point2D{0.00f, 0.05f};  /* pan up */
 
    engine.SetParameters(params);
    engine.Process(img, dst);
  }
}
</syntaxhighlight>


==GstRrPanoramaptz==
==GstRrPanoramaptz==
102

edits