Skip to content

Commit ec627be

Browse files
committed
2 parents 442d715 + 5c03ab7 commit ec627be

28 files changed

+1886
-158
lines changed

nvJPEG/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Image Encoding and Decoding from NVJPEG Library
1414

1515
[JPEG Image Decoder MultipleInstances](nvJPEG-Decoder-MultipleInstances/)
1616

17+
[JPEG Image Decoder Backend and ROI](nvJPEG-Decoder-Backend-ROI/)
18+
1719
[Image Resize](Image-Resize/)
1820

1921
[Image Resize Watermarking](Image-Resize-WaterMark/)
@@ -36,5 +38,5 @@ x86_64
3638

3739
# Prerequisites
3840
- A Linux system with recent NVIDIA drivers.
39-
- Install the [CUDA 11.0 toolkit](https://developer.nvidia.com/cuda-downloads).
41+
- Install the [CUDA 11.0 toolkit and above](https://developer.nvidia.com/cuda-downloads).
4042

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#
2+
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
3+
#
4+
# NVIDIA CORPORATION and its licensors retain all intellectual property
5+
# and proprietary rights in and to this software, related documentation
6+
# and any modifications thereto. Any use, reproduction, disclosure or
7+
# distribution of this software and related documentation without an express
8+
# license agreement from NVIDIA CORPORATION is strictly prohibited.
9+
#
10+
11+
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
12+
13+
project(nvJPEGROIDecode LANGUAGES CXX CUDA)
14+
15+
# ---[ Project specIFication.
16+
SET(PROJECT_NAME nvJPEGROIDecode)
17+
PROJECT(${PROJECT_NAME} LANGUAGES CUDA CXX)
18+
19+
if(NOT DEFINED CMAKE_CUDA_STANDARD)
20+
set(CMAKE_CUDA_STANDARD 11)
21+
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
22+
endif()
23+
24+
set(CMAKE_CXX_STANDARD 11)
25+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
26+
set(CMAKE_CXX_EXTENSIONS OFF)
27+
28+
29+
include_directories(
30+
SYSTEM ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
31+
)
32+
33+
34+
SET(EXAMPLES_DESCRIPTOR_SOURCES "nvJPEGROIDecode.cpp")
35+
36+
add_executable(nvJPEGROIDecode ${EXAMPLES_DESCRIPTOR_SOURCES})
37+
38+
find_library(NVJPEG_LIB
39+
NAMES nvjpeg
40+
PATHS ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
41+
42+
find_library(CUDART_LIB
43+
NAMES cudart
44+
PATHS ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
45+
46+
target_link_libraries(nvJPEGROIDecode PUBLIC ${NVJPEG_LIB} ${CUDART_LIB} pthread)
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# nvJPEG-Decoder-DifferentBackEnd
2+
3+
## Description
4+
The sample codes shows the usage of decouple nvJPEG API on decoding JPEG images. Extra functionalities including different backends and ROI are supported.
5+
6+
## Key Concepts
7+
Image Decoding, different backends from NVJPEG Library
8+
9+
## Supported SM Architecture
10+
SM 3.0 SM 3.5 SM 3.7 SM 5.0 SM 5.2 SM 6.0 SM 6.1 SM 7.0 SM 7.2 SM 7.5 8.0
11+
12+
## Supported OS
13+
Linux, Windows
14+
15+
## Supported CPU Architecture
16+
x86_64
17+
18+
## CUDA APIs involved
19+
NVJPEG
20+
21+
# Building
22+
Build command
23+
```
24+
$ mkdir build
25+
$ cd build
26+
$ cmake ..
27+
$ make
28+
```
29+
30+
# Usage
31+
```
32+
Usage: ./nvJPEGROIDecode -i images_dir [-roi roi_regions] [-backend backend_enum] [-b batch_size] [-t total_images] [-w warmup_iterations] [-o output_dir] [-pipelined] [-batched] [-fmt output_format]
33+
Parameters:
34+
images_dir : Path to single image or directory of images
35+
roi_regions : Specify the ROI in the following format [x_offset, y_offset, roi_width, roi_height]
36+
backend_eum : Type of backend for the nvJPEG (0 - NVJPEG_BACKEND_DEFAULT, 1 - NVJPEG_BACKEND_HYBRID,
37+
2 - NVJPEG_BACKEND_GPU_HYBRID)
38+
batch_size : Decode images from input by batches of specified size
39+
total_images : Decode this much images, if there are less images
40+
in the input than total images, decoder will loop over the input
41+
warmup_iterations : Run this amount of batches first without measuring performance
42+
output_dir : Write decoded images as BMPs to this directory
43+
pipelined : Use decoding in phases
44+
batched : Use batched interface
45+
output_format : nvJPEG output format for decoding. One of [rgb, rgbi, bgr, bgri, yuv, y, unchanged]
46+
```
47+
48+
# Example 1 - Choosing different backend
49+
**Default Backend**
50+
<br />
51+
Command: ./nvJPEGROIDecode -i ../input_images/ -backend 0
52+
```
53+
...
54+
...
55+
Total decoding time: 17.238
56+
Avg decoding time per image: 1.4365
57+
Avg images per sec: 0.696136
58+
Avg decoding time per batch: 1.4365
59+
```
60+
61+
**Hybrid BackEnd**
62+
<br />
63+
Command: ./nvJPEGROIDecode -i ../input_images/ -backend 1
64+
```
65+
...
66+
...
67+
Total decoding time: 13.9479
68+
Avg decoding time per image: 1.16233
69+
Avg images per sec: 0.860344
70+
Avg decoding time per batch: 1.16233
71+
```
72+
73+
**GPU Backend**
74+
<br />
75+
Command: ./nvJPEGROIDecode -i ../input_images/ -backend 2
76+
```
77+
...
78+
...
79+
Total decoding time: 20.5875
80+
Avg decoding time per image: 1.71563
81+
Avg images per sec: 0.582877
82+
Avg decoding time per batch: 1.71563
83+
```
84+
85+
# Example 2 - Decode with ROI
86+
Command: ./nvJPEGROIDecode -i ../input_images/ -roi 0,0,64,64
87+
88+
Original image:
89+
<br />
90+
![Original Image](./input_images/img9.jpg)
91+
<br />
92+
<br />
93+
Result:
94+
<br />
95+
![Result](img9_roi.png)
96+
97+
98+
99+
100+
101+
102+
103+
104+
105+
106+
48.2 KB
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)