https://github.com/tfussell/xlnt

 

GitHub - tfussell/xlnt: Cross-platform user-friendly xlsx library for C++11+

:bar_chart: Cross-platform user-friendly xlsx library for C++11+ - GitHub - tfussell/xlnt: Cross-platform user-friendly xlsx library for C++11+

github.com

 

Windows

> cd vcpkg
> ./vcpkg install xlnt:x64-windows

Linux

$ git clone https://github.com/microsoft/vcpkg.git
$ cd vcpkg
$ ./bootstrap-vcpkg.sh
$ sudo ./vcpkg integrate install
$ ./vcpkg install xlnt
...
-- Configuring x64-linux
-- Building x64-linux-dbg
-- Building x64-linux-rel
-- Installing: /home/jym/dev/vcpkg/packages/xlnt_x64-linux/share/xlnt/copyright
-- Fixing pkgconfig file: /home/jym/dev/vcpkg/packages/xlnt_x64-linux/lib/pkgconfig/xlnt.pc
-- Fixing pkgconfig file: /home/jym/dev/vcpkg/packages/xlnt_x64-linux/debug/lib/pkgconfig/xlnt.pc
...
xlnt provides CMake targets:

    # this is heuristically generated, and may not be correct
    find_package(Xlnt CONFIG REQUIRED)
    target_link_libraries(main PRIVATE xlnt::xlnt)

 

Specify the toolchain as a CMake option:

-DCMAKE_TOOLCHAIN_FILE=/home/jym/dev/vcpkg/scripts/buildsystems/vcpkg.cmake

But this won't work if you already specify a toolchain, such as when cross-compiling.

To avoid this problem, include it.

include(/home/jym/dev/vcpkg/scripts/buildsystems/vcpkg.cmake)

 

Example: CMakeLists.txt

cmake_minimum_required(VERSION 3.16)
project(test-xlnt CXX)

set(CMAKE_VERBOSE_MAKEFILE true)
set(CMAKE_CXX_STANDARD 14)

include(/home/jym/dev/vcpkg/scripts/buildsystems/vcpkg.cmake)

list(APPEND CMAKE_PREFIX_PATH "/home/jym/dev/vcpkg/installed/x64-linux/share")

find_package(Xlnt CONFIG REQUIRED)

message("XLNT_CMAKE_DIR:   ${XLNT_CMAKE_DIR}")
message("xlnt_INCLUDE_DIR: ${xlnt_INCLUDE_DIR}")

set(SRC_FILES main.cpp)

add_executable(${PROJECT_NAME} ${SRC_FILES})

target_include_directories(${PROJECT_NAME} PRIVATE
    ${xlnt_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} PRIVATE
    xlnt::xlnt)

 

다른 방법:

Findxlnt.cmake

# Findxlnt.cmake
#
# Finds the xlnt library
#
# This will define the following variables
#
#   xlnt_FOUND
#   xlnt_LIBRARY
#   xlnt_LIBRARIES
#   xlnt_LIBRARY_DEBUG
#   xlnt_LIBRARY_RELEASE
#
# and the following imported targets
#
#   xlnt::xlnt
#
# Author: John Coffey - johnco3@gmail.com
#

find_path(xlnt_INCLUDE_DIR NAMES xlnt/xlnt.hpp)

if (NOT xlnt_LIBRARIES)
    find_library(xlnt_LIBRARY_RELEASE NAMES xlnt DOC "xlnt release library")
    find_library(xlnt_LIBRARY_DEBUG NAMES xlntd DOC "xlnt debug library")
    include(SelectLibraryConfigurations)
    select_library_configurations(xlnt)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(xlnt
    REQUIRED_VARS xlnt_INCLUDE_DIR xlnt_LIBRARY)
mark_as_advanced(
    xlnt_INCLUDE_DIR
    xlnt_LIBRARY)

if(xlnt_FOUND AND NOT (TARGET xlnt::xlnt))
    # debug output showing the located libraries
    message(STATUS "xlnt_INCLUDE_DIR=${xlnt_INCLUDE_DIR}")
    message(STATUS "xlnt_LIBRARY=${xlnt_LIBRARY}")
    message(STATUS "xlnt_LIBRARIES=${xlnt_LIBRARIES}")
    message(STATUS "xlnt_LIBRARY_DEBUG=${xlnt_LIBRARY_DEBUG}")
    message(STATUS "xlnt_LIBRARY_RELEASE=${xlnt_LIBRARY_RELEASE}")
    # Add a blank imported library
    add_library(xlnt::xlnt UNKNOWN IMPORTED)

    # add the transitive includes property
    set_target_properties(xlnt::xlnt PROPERTIES
        INTERFACE_INCLUDE_DIRECTORIES "${xlnt_INCLUDE_DIR}")

    # Optimized library
    if(xlnt_LIBRARY_RELEASE)
        set_property(TARGET xlnt::xlnt APPEND PROPERTY
            IMPORTED_CONFIGURATIONS RELEASE)
        set_target_properties(xlnt::xlnt PROPERTIES
            IMPORTED_LOCATION_RELEASE "${xlnt_LIBRARY_RELEASE}")
    endif()

    # Debug library
    if(xlnt_LIBRARY_DEBUG)
        set_property(TARGET xlnt::xlnt APPEND PROPERTY
            IMPORTED_CONFIGURATIONS DEBUG)
        set_target_properties(xlnt::xlnt PROPERTIES
            IMPORTED_LOCATION_DEBUG "${xlnt_LIBRARY_DEBUG}")
    endif()

    # some other configuration
    if(NOT xlnt_LIBRARY_RELEASE AND NOT xlnt_LIBRARY_DEBUG)
        set_property(TARGET xlnt::xlnt APPEND PROPERTY
            IMPORTED_LOCATION "${xlnt_LIBRARY}")
    endif()
endif()

CMakeLists.txt 수정

...
# For finding Findxlnt.cmake
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake")
find_package(xlnt REQUIRED)

message("xlnt_INCLUDE_DIR: ${xlnt_INCLUDE_DIR}")
message("xlnt_LIBRARY:     ${xlnt_LIBRARY}")
message("xlnt_LIBRARIES:   ${xlnt_LIBRARIES}")
...

 

 

 

'C, C++' 카테고리의 다른 글

To install the MinGW-w64 toolchain  (0) 2022.10.28
문자열 구분자로 분리  (0) 2021.10.20
VSCode + vcpkg  (0) 2021.10.19
Get DLL path at run time  (0) 2021.10.05
ticktock  (0) 2021.08.15

Reference: https://www.baeldung.com/linux/ffmpeg-cutting-videos

1. Clipping with Re-Encoding

Video encoding is the process of compressing and preparing a video for output,

thus, making video sizes reasonably small and quick to process.

By default, the re-encoding will use the codec used in the orignal video.

$ ffmpeg -i input.mp4 -ss 00:00:15 -t 00:00:10 -async -1 output.mp4
  • -i input.mp4 : used for specifying input files
  • -ss 00:12:34 : seeks to the timestamp specified
  • -t 00:10:00 : used to specify the duration of the clip
  • -async -1 : spcifies whether to contract or stretch the audio to match the timestamp.
    The value 1 will correct the start of the stream without any later correction.

Alternatively, if we need a more time-accurate cut,

we can manually add the keyframes to the start and end of the clipped video:

$ ffmpeg -i input.mp4 -force_key_frames 00:00:15,00:00:25 output.mp4
  • -force_key_frames : video clipping occurs at keyframes
    However, if the first frame is not a keyframe,
    then the frames before the first keyframe in the clip will not be playable.
    Therefore, we forced FFmpeg to add keyframes at the first and last frames to ensure we encode a perfect clip.
    Moreover, to limit errors, we should avoid adding lots of keyframes.

 

2. Clipping Instantly via Stream Copy

FFmpeg allows for copying the codec from the orignal video to the trimmed video,
which takes only a few seconds.

$ ffmpeg -i input.mp4 -ss 00:00:15 -to 00:00:25 -c copy output.mp4
  • -to : specifies the end of the clip. (from 00:0015 to 00:00:25)
  • -c : to copy both audio and video codecs to the output.mp4 container

If we're using different containers,

we'll be presented with a container mismatch error.

If we have two different containers, we can specify the copying options separately.

$ ffmpeg -i input.mkv -ss 00:00:15 -to 00:00:25 -acodec copy -vcodec copy output.mp4

 

3. Clipping Using the trim Filter

It's useful when we have a short video, preferably less than a minute,

and we want to cut a small portion of it:

$ ffmpeg -i input -vf trim=10:25,setpts=PTS-STARTPTS output.mp4
  • -vf : specifies that we're using a video filter
  • We provided the trim filter with the value 10:25,
    which will slice the video from 00:00:10 to 00:00:25.
  • The setpts filter sets the presentation timestamp for each video frame in the clip.
    We set its value to be PTS-STARTPTS to make sure our clip doesn't delay or halt at the start,
    and the frames are synchronized relative to the setpts value, which is 0.

 

 

 

'C, C++ > FFmepg' 카테고리의 다른 글

FFmpeg CLI Tips  (0) 2021.09.01
FFmpeg CLI  (0) 2021.08.15

DeepStream 6.1.1 Is the release with support for Ubuntu 20.04 LTS

 

Microsoft Store에서 "Ubuntu 20.04.5 LTS" 설치

WSL은 기본 설치 경로가 사용자 디렉토리다.

(C:\Users\user\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04LTS_79rhkp1fndgsc\LocalState\ext4.vhdx)

 

Windows 상에서 네트워크 드라이브 연결

Install DeepStream

https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Quickstart.html

 

Quickstart Guide — DeepStream 6.1.1 Release documentation

Quickstart Guide NVIDIA® DeepStream Software Development Kit (SDK) is an accelerated AI framework to build intelligent video analytics (IVA) pipelines. DeepStream runs on NVIDIA® T4, NVIDIA® Ampere and platforms such as NVIDIA® Jetson AGX Xavier™, NV

docs.nvidia.com

dGPU Setup for Ubuntu

더보기

NOTE:

This document uses the term dGPU (“discrete GPU”) to refer to NVIDIA GPU expansion card products such as NVIDIA Tesla® T4 , NVIDIA GeForce® GTX 1080, NVIDIA GeForce® RTX 2080 and NVIDIA GeForce® RTX 3080. This version of DeepStream SDK runs on specific dGPU products on x86_64 platforms supported by NVIDIA driver 515.65.01 and NVIDIA TensorRT™ 8.4.1.5 and later versions.

 

You must install the following components:

  • GStreamer 1.16.2
  • NVIDIA driver 515.65.01
  • CUDA 11.7 update 1
  • TensorRT 8.4.1.5

Remove all previous DeepStream installations

To remove DeepStream 4.0 or later installations:

  1. Open the uninstall.sh file in /opt/nvidia/deepstream/deepstream/
  2. Set PREV_DS_VER as 4.0
  3. Run the following script as
$ sudo ./uninstall.sh

Install Dependencies

$ sudo apt -y install \
    libssl1.1 \
    libgstreamer1.0-0   \
    libgstreamer1.0-dev \
    gstreamer1.0-tools        \
    gstreamer1.0-plugins-good \
    gstreamer1.0-plugins-bad  \
    gstreamer1.0-plugins-ugly \
    gstreamer1.0-libav        \
    libgstreamer-plugins-base1.0-dev \
    libgstrtspserver-1.0-0   \
    libgstrtspserver-1.0-dev \
    libjansson4 \
    libjson-glib-dev \
    libyaml-cpp-dev \
    gcc \
    make \
    git \
    python3 python-is-python3

 

https://docs.nvidia.com/cuda/archive/11.7.1/wsl-user-guide/index.html

 

CUDA on WSL :: CUDA Toolkit Documentation

Whether to efficiently use hardware resources or to improve productivity, virtualization is a more widely used solution in both consumer and enterprise space. There are different types of virtualizations, and it is beyond the scope of this document to delv

docs.nvidia.com

 

[OS/Linux] - CUDA 11.7.1 on WSL2

 

Install TensorRT 8.4.1.5

$ sudo apt-get -y install \
    libnvinfer8=8.4.1-1+cuda11.6 \
    libnvinfer-plugin8=8.4.1-1+cuda11.6 \
    libnvparsers8=8.4.1-1+cuda11.6 \
    libnvonnxparsers8=8.4.1-1+cuda11.6 \
    libnvinfer-bin=8.4.1-1+cuda11.6 \
    libnvinfer-dev=8.4.1-1+cuda11.6 \
    libnvinfer-plugin-dev=8.4.1-1+cuda11.6 \
    libnvparsers-dev=8.4.1-1+cuda11.6 \
    libnvonnxparsers-dev=8.4.1-1+cuda11.6 \
    libnvinfer-samples=8.4.1-1+cuda11.6 \
    libcudnn8=8.4.1.50-1+cuda11.6 \
    libcudnn8-dev=8.4.1.50-1+cuda11.6 \
    python3-libnvinfer=8.4.1-1+cuda11.6 \
    python3-libnvinfer-dev=8.4.1-1+cuda11.6
더보기

NOTE:

$sudo dpkg -i cudnn-local-repo-ubuntu2004-8.4.1.50_1.0-1_amd64.deb``
$sudo apt-get update
$sudo apt install libcudnn8=8.4.1.50-1+cuda11.6 libcudnn8-dev=8.4.1.50-1+cuda11.6

 

Install librdkafka (to enable Kafka protocol adaptor for message broker)

1. Clone the librdkafka repository from GitHub:

2. Configure and build the library:

$ git clone https://github.com/edenhill/librdkafka.git

$ cd librdkafka
$ git reset --hard 7101c2310341ab3f4675fc565f64f0967e135a6a
$ ./configure
$ make
make[1]: Entering directory '/home/ym/dev/librdkafka/src'
...
Generating linker script librdkafka.lds from rdkafka.h
/usr/bin/env: ‘python’: No such file or directory
make[1]: *** [Makefile:79: librdkafka.lds] Error 127
make[1]: Leaving directory '/home/ym/dev/librdkafka/src'
make: *** [Makefile:20: libs] Error 2

$ whereis python3
python3: /usr/bin/python3.8 /usr/bin/python3 /usr/lib/python3.8 /usr/lib/python3.9 /usr/lib/python3 /etc/python3.8 /etc/python3 /usr/local/lib/python3.8 /usr/share/python3 /mnt/c/Users/jylee/AppData/Local/Microsoft/WindowsApps/python3.exe /mnt/c/msys64/mingw64/bin/python3.10-config /mnt/c/msys64/mingw64/bin/python3.exe /usr/share/man/man1/python3.1.gz

#$ sudo ln -s /usr/bin/python3 /usr/bin/python
$ sudo apt install python-is-python3

$ make
make[1]: Entering directory '/home/ym/dev/librdkafka/src'
...
Updating
CONFIGURATION.md CONFIGURATION.md.tmp differ: byte 345, line 6
Checking  integrity
CONFIGURATION.md               OK
examples/rdkafka_example       OK
examples/rdkafka_performance   OK
examples/rdkafka_example_cpp   OK
make[1]: Entering directory '/home/ym/dev/librdkafka/src'
Checking librdkafka integrity
librdkafka.so.1                OK
librdkafka.a                   OK
Symbol visibility              OK
make[1]: Leaving directory '/home/ym/dev/librdkafka/src'
make[1]: Entering directory '/home/ym/dev/librdkafka/src-cpp'
Checking librdkafka++ integrity
librdkafka++.so.1              OK
librdkafka++.a                 OK
make[1]: Leaving directory '/home/ym/dev/librdkafka/src-cpp'

$ sudo make install

If Python3 has been installed, run these commands: whereis python3

Then we create a symlink to it: sudo ln -s /usr/bin/python3 /usr/bin/python

 

3. Copy the generated libraries to the deepstream directory:

$ sudo mkdir -p /opt/nvidia/deepstream/deepstream-6.1/lib
$ sudo cp /usr/local/lib/librdkafka* /opt/nvidia/deepstream/deepstream-6.1/lib

 

Install the DeepStream SDK

Method 1: Using the DeepStream Debian package

Download the DeepStream 6.1.1 dGPU Debian package deepstream-6.1_6.1.1-1_amd64.deb:

https://developer.nvidia.com/deepstream-6.1_6.1.1-1_amd64.deb

$ sudo apt-get install ./deepstream-6.1_6.1.1-1_amd64.deb
...
---------------------------------------------------------------------------------------
NOTE: sources and samples folders will be found in /opt/nvidia/deepstream/deepstream-6.1
---------------------------------------------------------------------------------------
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...

 

Run the deepstream-app (the reference application)

Go to the samples directory and enter this command:

$ deepstream-app -c <path_to_config_file>

 

Run precompiled sample applications

1. Navigate to the chosen application directory inside sources/apps/samples_apps.

2. Follow that directory's README file to run the application.

더보기

NOTE:

If the application encounters errors and cannot create Gst elements, remove the GStreamer cache, then try again. To remove the GStreamer cache, enter this command:

$ rm ${HOME}/.cache/gstreamer-1.0/registry.x86_64.bin

When the application is run for a model which does not have an existing engine file, it may take up to a few minutes (depending on the platform and the model) for the file generation and application launch. For later runs, these generated engine files can be reused for faster loading.

 

'C, C++ > DeepStream' 카테고리의 다른 글

Crop and Resize Objects  (0) 2022.11.08

How does secondary GIE crop and resize objects?

SGIE will crop the object from NvStreamMux buffer using the object’s bbox detected by the Primary GIE.

The crop is then scaled/converted to the network resolution/color format.

For example, if the NvStreamMux resolution is 1920x1080, SGIE will crop using object bbox co-ordinates

(e.g. x=1000, y=20, w=400, y=500) from the 1920x1080 image and then scale it to the SGIE network resolution (say 224x224).

In practice, the object crop + scaling + color conversion happens in one go.

 

How to save frames from GstBuffer?

To save frames from gst buffer you need to Map gst buffer using gst_buffer_map () API.

Here is the pseudo code:

GstMapInfo in_map_info;
NvBufSurface *surface = NULL;

memset(&in_map_info, 0, sizeof(in_map_info));
if (!gst_buffer_map(inbuf, &in_map_info, GST_MAP_READ)) {
    g_print ("Error: Failed to map gst buffer\n");
}
surface = (NvBufSurface*)in_map_info.data;

Now that you have access to NvBufSurface structure, you can access actual frame memory and save it.

At the end you need to unmap gst buffer using gst_buffer_unmap (inbuf, &in_map_info)

For more details, see gst_dsexample_transform_ip() in gst-dsexample plugin source code.

 

 

 

 

 

'C, C++ > DeepStream' 카테고리의 다른 글

Install DeepStream 6.1.1 on WSL2  (0) 2022.11.08

https://www.msys2.org/

 

MSYS2

Software Distribution and Building Platform for Windows

www.msys2.org

 

1. Open MSYS2 shell from start menu

2. Run ... to update the package database

$ pacman -Sy pacman

3. Re-open the shell, run ... to update the package database and core system packages

$ pacman -Syu

4. Re-open the shell, run ... to update the rest

$ pacman -Su

5. Install compiler:

$ pacman -S mingw-w64-x86_64-toolchain

6. Select which package to install, default is all

7. You may also need make, run ...

$ pacman -S make

8. cmake

$ pacman -S mingw-w64-x86_64-cmake

'C, C++' 카테고리의 다른 글

xlnt - XLSX 파일 다루기  (0) 2022.12.22
문자열 구분자로 분리  (0) 2021.10.20
VSCode + vcpkg  (0) 2021.10.19
Get DLL path at run time  (0) 2021.10.05
ticktock  (0) 2021.08.15

+ Recent posts