29 #include <opencv2/core/version.hpp>
30 #include <opencv2/imgcodecs.hpp>
31 #include <opencv2/imgproc/imgproc.hpp>
46 #define CHECK_STATUS(STMT) \
49 VPIStatus status = (STMT); \
50 if (status != VPI_SUCCESS) \
52 char buffer[VPI_MAX_STATUS_MESSAGE_LENGTH]; \
53 vpiGetLastStatusMessage(buffer, sizeof(buffer)); \
54 std::ostringstream ss; \
55 ss << vpiStatusGetName(status) << ": " << buffer; \
56 throw std::runtime_error(ss.str()); \
60 int main(
int argc,
char *argv[])
84 throw std::runtime_error(std::string(
"Usage: ") + argv[0] +
" <input image>");
87 std::string strInputFileName = argv[1];
90 cvImage = cv::imread(strInputFileName);
93 throw std::runtime_error(
"Can't open '" + strInputFileName +
"'");
100 const int parentWidth = cvImage.cols, parentHeight = cvImage.rows;
103 const int viewWidth = parentWidth / 2, viewHeight = parentHeight / 2;
105 if ((viewWidth == 0) || (viewHeight == 0))
107 throw std::runtime_error(std::string(
"Input image too small, it must be at least 2x2"));
119 for (
int i = 0; i < 4; ++i)
127 clipBounds.x =
static_cast<int>(i % 2) * viewWidth;
128 clipBounds.y =
static_cast<int>(i / 2) * viewHeight;
129 clipBounds.width = viewWidth;
130 clipBounds.height = viewHeight;
183 imwrite(
"output_views.png", cvOut);
188 catch (std::exception &e)
190 std::cerr << e.what() << std::endl;
197 for (
int i = 0; i < 4; ++i)
199 if (streams[i] != NULL)
206 for (
int i = 0; i < 4; ++i)
Declares functions that implement the Bilateral Filter algorithm.
Functions and structures for dealing with VPI events.
Declares functions that implement Image flip algorithms.
Functions and structures for dealing with VPI images.
Functions for handling OpenCV interoperability with VPI.
Declaration of VPI status codes handling functions.
Declares functions dealing with VPI streams.
@ VPI_FLIP_HORIZ
Flip horizontally.
@ VPI_FLIP_VERT
Flip vertically.
@ VPI_FLIP_BOTH
Flip horizontally and vertically.
VPIStatus vpiSubmitBilateralFilter(VPIStream stream, uint64_t backend, VPIImage input, VPIImage output, int32_t kernelSize, float sigmaRange, float sigmaSpace, VPIBorderExtension border)
Runs a 2D bilateral filter over an image.
struct VPIEventImpl * VPIEvent
A handle to an event.
VPIStatus vpiEventRecord(VPIEvent event, VPIStream stream)
Captures in the event the contents of the stream command queue at the time of this call.
VPIStatus vpiEventCreate(uint64_t flags, VPIEvent *event)
Create an event instance.
void vpiEventDestroy(VPIEvent event)
Destroy an event instance as well as all resources it owns.
VPIStatus vpiSubmitImageFlip(VPIStream stream, uint64_t backend, VPIImage input, VPIImage output, VPIFlipMode flipMode)
Flips a 2D image either horizontally, vertically or both.
VPIImageBufferType bufferType
Type of image buffer.
void vpiImageDestroy(VPIImage img)
Destroy an image instance.
struct VPIImageImpl * VPIImage
A handle to an image.
VPIStatus vpiImageCreateView(VPIImage imgParent, const VPIRectangleI *clipBounds, uint64_t flags, VPIImage *imgView)
Create an image that wraps an axis-aligned rectangular sub-region of an existing image.
VPIStatus vpiImageLockData(VPIImage img, VPILockMode mode, VPIImageBufferType bufType, VPIImageData *data)
Acquires the lock on an image object and returns the image contents.
VPIStatus vpiImageCreate(int32_t width, int32_t height, VPIImageFormat fmt, uint64_t flags, VPIImage *img)
Create an empty image instance with the specified flags.
VPIStatus vpiImageUnlock(VPIImage img)
Releases the lock on an image object.
@ VPI_IMAGE_BUFFER_HOST_PITCH_LINEAR
Host-accessible with planes in pitch-linear memory layout.
Stores information about image characteristics and content.
VPIStatus vpiImageCreateWrapperOpenCVMat(const cv::Mat &mat, VPIImageFormat fmt, uint64_t flags, VPIImage *img)
Wraps a cv::Mat in an VPIImage with the given image format.
VPIStatus vpiImageDataExportOpenCVMat(const VPIImageData &imgData, cv::Mat *mat)
Fills an existing cv::Mat with data from VPIImageData coming from a locked VPIImage.
struct VPIStreamImpl * VPIStream
A handle to a stream.
VPIStatus vpiStreamWaitEvent(VPIStream stream, VPIEvent event)
Pushes a command that blocks the processing of all future commands submitted to the stream until the ...
VPIStatus vpiStreamSync(VPIStream stream)
Blocks the calling thread until all submitted commands in this stream queue are done (queue is empty)...
void vpiStreamDestroy(VPIStream stream)
Destroy a stream instance and deallocate all HW resources.
VPIStatus vpiStreamCreate(uint64_t flags, VPIStream *stream)
Create a stream instance.
@ VPI_BACKEND_CUDA
CUDA backend.
@ VPI_BACKEND_CPU
CPU backend.
@ VPI_BORDER_ZERO
All pixels outside the image are considered to be zero.
@ VPI_LOCK_READ
Lock memory only for reading.
Stores the geometric information of a rectangle.