Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/_debugbuild/aprapipesut",
"args": ["--run_test=virtualcamerasink_tests/perf"],
"program": "${workspaceFolder}/_build/aprapipesut",
"args": ["--run_test=logger_tests"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ git clone --recursive https://github.com/Apra-Labs/ApraPipes.git

## Prerequisites
* Run ```sudo apt-get update && sudo apt-get install build-essential``` to get latest build tools
* CMake minimum version 3.14 - Follow [this article](https://anglehit.com/how-to-install-the-latest-version-of-cmake-via-command-line/) to update cmake
* CMake minimum version 3.17 - Follow [this article](https://anglehit.com/how-to-install-the-latest-version-of-cmake-via-command-line/) to update cmake
* ffmpeg
```
sudo apt install yasm -y
Expand Down
51 changes: 26 additions & 25 deletions base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ IF(ENABLE_ARM64)
ENDIF(ENABLE_ARM64)

project(APRAPIPES)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)

hunter_add_package(Boost COMPONENTS system thread filesystem serialization log chrono)
find_package(Boost CONFIG REQUIRED system thread filesystem serialization log chrono)
Expand Down Expand Up @@ -60,13 +60,13 @@ find_library(LIB_AVFORMAT libavformat.a PATHS ${FFMPEG_ROOT}/libavformat NO_DEFA
find_library(LIB_AVCODEC libavcodec.a PATHS ${FFMPEG_ROOT}/libavcodec NO_DEFAULT_PATH)
find_library(LIB_AVUTIL libavutil.a PATHS ${FFMPEG_ROOT}/libavutil NO_DEFAULT_PATH)
find_library(LIB_FFSWR libswresample.a PATHS ${FFMPEG_ROOT}/libswresample NO_DEFAULT_PATH)
find_library(LIB_ZXING libZXing.a PATHS ../thirdparty/zxing-cpp/_install/lib NO_DEFAULT_PATH)
find_library(LIB_ZXING libZXing.a PATHS ../thirdparty/zxing-cpp/_build/zxing-cpp.release/core NO_DEFAULT_PATH)


IF(ENABLE_CUDA)
IF(ENABLE_ARM64)
SET(NVCODEC_LIB)
SET ( JETSON_MULTIMEDIA_LIB_INCLUDE "/usr/src/jetson_multimedia_api/include" )
SET ( JETSON_MULTIMEDIA_LIB_INCLUDE "/usr/src/jetson_multimedia_api/include" )

list(APPEND CMAKE_PREFIX_PATH /usr/lib/aarch64-linux-gnu/tegra)
list(APPEND CMAKE_PREFIX_PATH /usr/lib/aarch64-linux-gnu/tegra-egl)
Expand All @@ -76,8 +76,8 @@ IF(ENABLE_CUDA)
find_library(EGLLIB EGL)
find_library(GLESv2LIB GLESv2)
find_library(X11LIB X11)
find_library(NVBUFUTILSLIB nvbuf_utils)
find_library(EGLSTREAM_CAMCONSUMER_LIB nveglstream_camconsumer)
find_library(NVBUFUTILSLIB nvbufsurface)
#find_library(EGLSTREAM_CAMCONSUMER_LIB nveglstream_camconsumer)
find_library(NVARGUS_SOCKETCLINET_LIB nvargus_socketclient)
find_package(Curses REQUIRED)

Expand All @@ -89,7 +89,7 @@ IF(ENABLE_CUDA)
${EGLLIB}
${GLESv2LIB}
${X11LIB}
${EGLSTREAM_CAMCONSUMER_LIB}
#${EGLSTREAM_CAMCONSUMER_LIB}
${NVARGUS_SOCKETCLINET_LIB}
)
ELSE()
Expand All @@ -103,7 +103,8 @@ IF(ENABLE_CUDA)
libnppig_static.a
libnppicc_static.a
libnppidei_static.a
libnppial_static.a
libnppial_static.a
libnppif_static.a
libculibos.a
)

Expand All @@ -113,11 +114,11 @@ ENDIF(ENABLE_CUDA)
include_directories(AFTER SYSTEM include
${BOOST_ROOT}/include
${OPENCV_ROOT}/include/opencv4
/usr/local/cuda-10.2/include
/usr/local/cuda/include
../thirdparty/Video_Codec_SDK_10.0.26/Interface
../thirdparty/ffmpeg/include
${CURSES_INCLUDE_DIR}
../thirdparty/zxing-cpp/_install/include/ZXing
../thirdparty/zxing-cpp/core/src
)

# ApraPipes library
Expand Down Expand Up @@ -264,11 +265,11 @@ SET(CUDA_IP_FILES
src/CCNPPI.cpp
src/EffectsKernel.cu
src/EffectsNPPI.cpp
src/GaussianBlur.cpp
#src/GaussianBlur.cpp
src/OverlayKernel.cu
src/OverlayNPPI.cpp
src/ResizeNPPI.cpp
src/RotateNPPI.cpp
# src/ResizeNPPI.cpp
# src/RotateNPPI.cpp
)

IF(ENABLE_ARM64)
Expand All @@ -287,10 +288,10 @@ IF(ENABLE_ARM64)
src/NvArgusCamera.cpp
src/NvV4L2Camera.cpp
src/NvV4L2CameraHelper.cpp
src/EglRenderer.cpp
src/NvEglRenderer.cpp
# src/EglRenderer.cpp
# src/NvEglRenderer.cpp
src/DMAUtils.cpp
src/NvTransform.cpp
# src/NvTransform.cpp
src/ApraEGLDisplay.cpp
src/DMAFDToHostCopy.cpp
)
Expand Down Expand Up @@ -374,26 +375,26 @@ IF (ENABLE_ARM64)
test/h264encoderv4l2helper_tests.cpp
test/h264encoderv4l2_tests.cpp
test/nvarguscamerahelper_tests.cpp
test/nvarguscamera_tests.cpp
test/nvv4l2camera_test.cpp
# test/nvarguscamera_tests.cpp
# test/nvv4l2camera_test.cpp
test/nvv4l2camerahelper_test.cpp
test/nvtransform_tests.cpp
test/eglrenderer_test.cpp
# test/nvtransform_tests.cpp
# test/eglrenderer_test.cpp
)
ENDIF(ENABLE_ARM64)

IF (ENABLE_CUDA)
SET(CUDA_UT_FILES
test/cudamemcopy_tests.cpp
test/resizenppi_tests.cpp
test/rotatenppi_tests.cpp
# test/resizenppi_tests.cpp
# test/rotatenppi_tests.cpp
)

IF(ENABLE_ARM64)
SET(CUDA_UT_FILES ${CUDA_UT_FILES}
test/cuda_arm_tests.cpp
test/apraegldisplay_tests.cpp
test/frame_factory_test_dma.cpp
SET(CUDA_UT_FILES ${CUDA_UT_FILES}
# test/cuda_arm_tests.cpp
# test/apraegldisplay_tests.cpp
# test/frame_factory_test_dma.cpp
)
ELSE()
SET(CUDA_UT_FILES ${CUDA_UT_FILES}
Expand Down
28 changes: 14 additions & 14 deletions base/include/DMAAllocator.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "Allocators.h"
#include "DMAFDWrapper.h"
#include "nvbuf_utils.h"
#include "nvbufsurface.h"
#include "FrameMetadataFactory.h"
#include "ApraEGLDisplay.h"
#include "Logger.h"
Expand All @@ -12,31 +12,31 @@ class DMAAllocator : public HostAllocator
private:
std::vector<DMAFDWrapper *> mDMAFDWrapperArr;
int mFreeDMACount;
NvBufferColorFormat mColorFormat;
NvBufSurfaceColorFormat mColorFormat;
EGLDisplay mEglDisplay;
int mHeight;
int mWidth;
int mCount;

static NvBufferColorFormat getColorFormat(ImageMetadata::ImageType imageType)
static NvBufSurfaceColorFormat getColorFormat(ImageMetadata::ImageType imageType)
{
NvBufferColorFormat colorFormat;
NvBufSurfaceColorFormat colorFormat;
switch (imageType)
{
case ImageMetadata::UYVY:
colorFormat = NvBufferColorFormat_UYVY;
colorFormat = NVBUF_COLOR_FORMAT_UYVY;
break;
case ImageMetadata::RGBA:
colorFormat = NvBufferColorFormat_ABGR32;
colorFormat = NVBUF_COLOR_FORMAT_RGBA;
break;
case ImageMetadata::BGRA:
colorFormat = NvBufferColorFormat_ARGB32;
colorFormat = NVBUF_COLOR_FORMAT_BGRA;
break;
case ImageMetadata::YUV420:
colorFormat = NvBufferColorFormat_YUV420;
colorFormat = NVBUF_COLOR_FORMAT_YUV420;
break;
case ImageMetadata::NV12:
colorFormat = NvBufferColorFormat_NV12;
colorFormat = NVBUF_COLOR_FORMAT_NV12;
break;
default:
throw AIPException(AIP_FATAL, "Expected <RGBA/BGRA/UYVY/YUV420/NV12> Actual<" + std::to_string(imageType) + ">");
Expand Down Expand Up @@ -97,14 +97,14 @@ class DMAAllocator : public HostAllocator
auto eglDisplay = ApraEGLDisplay::getEGLDisplay();
auto colorFormat = getColorFormat(imageType);

auto dmaFDWrapper = DMAFDWrapper::create(0, width, height, colorFormat, NvBufferLayout_Pitch, eglDisplay);
auto dmaFDWrapper = DMAFDWrapper::create(0, width, height, colorFormat, NVBUF_LAYOUT_PITCH, eglDisplay);
if (!dmaFDWrapper)
{
LOG_ERROR << "Failed to allocate dmaFDWrapper";
throw AIPException(AIP_FATAL, "Memory Allocation Failed.");
}

NvBufferParams fdParams;
#ifdef JP512_TBD
NvBufSurfaceParams fdParams;
if (NvBufferGetParams(dmaFDWrapper->getFd(), &fdParams))
{
throw AIPException(AIP_FATAL, "NvBufferGetParams Failed.");
Expand Down Expand Up @@ -155,15 +155,15 @@ class DMAAllocator : public HostAllocator
throw AIPException(AIP_FATAL, "Expected Raw Image or RAW_IMAGE_PLANAR. Actual<" + std::to_string(frameType) + ">");
break;
}

#endif
delete dmaFDWrapper;
}

void *allocateChunks(size_t n)
{
if (mFreeDMACount == 0)
{
auto dmaFDWrapper = DMAFDWrapper::create(mCount++, mWidth, mHeight, mColorFormat, NvBufferLayout_Pitch, mEglDisplay);
auto dmaFDWrapper = DMAFDWrapper::create(mCount++, mWidth, mHeight, mColorFormat, NVBUF_LAYOUT_PITCH, mEglDisplay);
if (!dmaFDWrapper)
{
LOG_ERROR << "Failed to allocate dmaFDWrapper";
Expand Down
8 changes: 4 additions & 4 deletions base/include/DMAFDWrapper.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "nvbuf_utils.h"
#include "nvbufsurface.h"
#include "EGL/egl.h"
#include "cudaEGL.h"

Expand All @@ -8,8 +8,8 @@ class DMAFDWrapper
public:
/* Always use this static method to create DMAFDWrapper */
static DMAFDWrapper *create(int index, int width, int height,
NvBufferColorFormat colorFormat,
NvBufferLayout layout, EGLDisplay eglDisplay);
NvBufSurfaceColorFormat colorFormat,
NvBufSurfaceLayout layout, EGLDisplay eglDisplay);

virtual ~DMAFDWrapper();

Expand Down Expand Up @@ -50,4 +50,4 @@ class DMAFDWrapper
const int index;

const void* clientData;
};
};
2 changes: 1 addition & 1 deletion base/include/DMAUtils.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "nvbuf_utils.h"
//#include "nvbuf_utils.h"
#include "EGL/egl.h"
#include "cudaEGL.h"

Expand Down
9 changes: 4 additions & 5 deletions base/include/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Logger {
static void initLogger(LoggerProps props);
static Logger* getLogger();
static void setLogLevel(boost::log::trivial::severity_level severity);
static void setListener(void(*cb)(std::string&));
static void setListener(void(*cb)(const std::string&));

virtual ~Logger();

Expand All @@ -59,7 +59,7 @@ class Logger {
void setFileLog(bool enableLog);
bool push(boost::log::trivial::severity_level level, std::ostringstream& stream);

void _setListener(void(*cb)(std::string&));
void _setListener(void(*cb)(const std::string&));

std::ostringstream& pre(std::ostringstream& stream, boost::log::trivial::severity_level lvl);
std::ostringstream& aipexceptionPre(std::ostringstream& stream, boost::log::trivial::severity_level lvl,int type);
Expand All @@ -72,12 +72,11 @@ class Logger {
threadsafe_que<std::string> mQue;
boost::thread myThread;
bool run();
bool process(std::string& message);
bool process(const std::string& message);
bool mRunning;
bool logDisabled;
LoggerProps mProps;

void(*mListener)(std::string&);
void(*mListener)(const std::string&);

static boost::shared_ptr<Logger> instance;
boost::log::sources::severity_logger< boost::log::trivial::severity_level > lg;
Expand Down
4 changes: 3 additions & 1 deletion base/include/NvV4L2CameraHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
#include <thread>
#include "ExtFrame.h"
#include "NvUtils.h"
#include "nvbuf_utils.h"
#ifdef JP512_TBD
#include "nvbuf_utils.h"
#endif
#include <map>
#include <mutex>

Expand Down
18 changes: 17 additions & 1 deletion base/include/QRReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,27 @@

#include "Module.h"
#include "ReadBarcode.h"
#include "TextUtfEncoding.h"

class QRReaderProps : public ModuleProps
{
public:
QRReaderProps() : ModuleProps() {}
QRReaderProps(bool _tryHarder = false, bool _saveQRImages = false, string _qrImagesPath = "", int _frameRotationCounter = 10) : ModuleProps()
{
tryHarder = _tryHarder;
saveQRImages = _saveQRImages;
qrImagesPath = _qrImagesPath;
frameRotationCounter = _frameRotationCounter;
}

size_t getSerializeSize()
{
return ModuleProps::getSerializeSize();
}
bool tryHarder;
bool saveQRImages;
string qrImagesPath;
int frameRotationCounter;
};

class QRReader : public Module
Expand Down
Loading