Friday, 14 January 2022

How to calculate the module time in C++ OpenCV?

method1: 

         double t = (double)cv::getTickCount();
        bool status = weightedMovingVariance(frame, output, count);
        t = ((double)cv::getTickCount() - t)/cv::getTickFrequency();
        std::cout << "Times passed in seconds: " << t << std::endl;


method2:

cv::TickMeter tm;
tm.start();
// do something ...
tm.stop();
std::cout << "Total time: " << tm.getTimeSec() << std::endl;

How to do smart indent in vim for C++ code?

 gg then =G

Wednesday, 12 January 2022

How to run spawn using a bash script?

/data/build/main1.sh &
P1=$!
/data/build/main2.sh &
P2=$!
wait $P1 $P2

Friday, 7 January 2022

How to fix corrupted pip?

wget https://bootstrap.pypa.io/pip/3.5/get-pip.py 

python get-pip.py

triton - how to set the batch size: dynamic versus predefined

predefined:-

name: "kps"
platform: "tensorrt_plan"
max_batch_size: 16
dynamic_batching {
  preferred_batch_size: [ 1,2,4,8,16 ]
  max_queue_delay_microseconds: 50
}

instance_group [
    {
      count: 16
      kind: KIND_GPU
      gpus: [ 0 ]
    }
]

input [
  {
    name: "input"
    data_type: TYPE_FP32
    format: FORMAT_NCHW
    dims: [ 3, 64, 64 ]
    reshape { shape: [ 3, 64, 64 ] }
  }
]
output [
  {
    name: "output1"
    data_type: TYPE_FP32
    dims: [ 1]
  },
  {
    name: "output2"
    data_type: TYPE_INT32
    dims: [ 1 ]
  },
  {
    name: "output3"
    data_type: TYPE_FP32
    dims: [ 8,64 ]
  }
]



version_policy: { all { } }
 

 

dynamic:-

platform: "tensorrt_plan"
max_batch_size: 0

instance_group [
    {
      count: 16
      kind: KIND_GPU
      gpus: [ 0 ]
    }
]


input [
  {
    name: "images"
    data_type: TYPE_FP32
    dims: [ -1,3, 640, 640]
  }
]
output [
  {
    name: "524"
    data_type: TYPE_FP32
    dims: [ -1,3,80,80, 7 ]
  },
      {
    name: "585"
    data_type: TYPE_FP32
    dims: [ -1,3,40,40, 7 ]
  },
  {
    name: "646"
    data_type: TYPE_FP32
    dims: [ -1,3,20,20, 7 ]
  },
  {
    name: "output"
    data_type: TYPE_FP32
    dims: [ -1, 25200, 7 ]
  }
]
~                                                                                                                                                                                                           
~                                                                                                                                                                                                           
~                                                                                                                                                                                                           
~                                             

Tuesday, 4 January 2022

cmake of VisionWorks

 cmake_minimum_required(VERSION 3.10)

#set the project name and version
project(render)

find_package(OpenCV REQUIRED)
find_package(CUDA 10.2 REQUIRED)

set(WITH_CUDA ON)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")

include_directories(${OpenCV_INCLUDE_DIRS})


add_executable(main main_nvgstcamera_capture.cpp)


target_include_directories(main PUBLIC
                -I/usr/local/cuda-10.2/targets/aarch64-linux/include
                /usr/share/visionworks/sources/nvxio/include
                /usr/share/visionworks/sources/nvxio/src/
                /usr/share/visionworks/sources/nvxio/src/NVX/
                /usr/share/visionworks/sources/3rdparty/opengl
                /usr/share/visionworks/sources/3rdparty/glfw3/include
                /usr/share/visionworks/sources/3rdparty/freetype/include
                /usr/share/visionworks/sources/3rdparty/eigen
)


target_link_libraries(main
            -L$(PKG_CONFIG_SYSROOT_DIR)/usr/lib
            /usr/share/visionworks/sources/libs/aarch64/linux/release/libovx.a
            /usr/share/visionworks/sources/3rdparty/freetype/libs/libfreetype.a
            /usr/share/visionworks/sources/3rdparty/glfw3/libs/libglfw3.a
            /usr/lib/aarch64-linux-gnu/tegra-egl/libGLESv2_nvidia.so.2
            -L/usr/lib/aarch64-linux-gnu
            -lEGL
            -lXrandr
            -lXi
            -lXxf86vm
            -lX11
            -lgstpbutils-1.0
            -lgstaudio-1.0
            -lgstvideo-1.0
            -lgstapp-1.0
            -lgstbase-1.0
            -lgstreamer-1.0
            -lgobject-2.0
            -lglib-2.0
            /usr/lib/aarch64-linux-gnu/tegra/libcuda.so
            -L/usr/local/cuda-10.2/targets/aarch64-linux/lib
            -lcudart
            -lvisionworks
                




            
            ${OpenCV_LIBS}
            )

Saturday, 1 January 2022

how to loop a string array in c++?

#include "iostream"

#include "string.h"


using namespace std;


int main()

{

    string strNames[] = { "Name1", "Name2", "Name3", "Name4", "Name5", "Name6"};


    for each(string name in strNames)

    {

       printf("%s\n", name.c_str());

    }

    return 0;

}