nppiHistogramEven help

• DeepStream Version
5.1

Hello, I’m trying to understand how to use nppiHistogramEven_8u_C3R_Ctx. The documentation is not very helpful.

Let’s assume the input image is a 3-channel BGR image with 1 pixel (values: 255,0,0). Let’s also assume the NvBufSurfaces (eg. full_img_hist) are created correctly along with the scratch buffer and the associated scratch buffer size (7178).

Given the following params:
int nLevels_3ch[3] = { 3, 3, 3 };
int nLowerLevel[3] = { 0, 0, 0 };
int nUpperLevel[3] = { 256, 256, 256 };
Npp32s* pHist[3] = {
( Npp32s* ) full_img_hist->surfaceList[0].dataPtr,
( ( Npp32s* ) full_img_hist->surfaceList[0].dataPtr ) + nLevels_3ch[0],
( ( Npp32s* ) full_img_hist->surfaceList[0].dataPtr ) + nLevels_3ch[1],
};

After calling: nppiHistogramEven_8u_C3R_Ctx(…)

I want to find out the number of pixels in each bin. So I’m casting it like:

int32_t bgr[3] = { -1, -1, -1 };
memcpy( &bgr[0], pHist[0], sizeof( int32_t ) );
memcpy( &bgr[1], pHist[1], sizeof( int32_t ) );
memcpy( &bgr[2], pHist[2], sizeof( int32_t ) );

  1. Is this the correct way to extract the output?
  2. What should the 3 values in the bgr array be?
  3. Given that it’s a 3-channel pixel and nLevels_3ch is initialised with the number 3 (implying 3 bins), should I receive 9 values? One for each bin of each channel?

here are some docs about nppiHistogramEven_8u_C3R_Ctx
http://gwmodel.whu.edu.cn/docs/CUDA/npp/group__image__histogrameven.html#CommonHistogramEvenParameters
https://www.clear.rice.edu/comp422/resources/cuda/html/npp/group__image__histogrameven.html#CommonHistogramEvenParameters

and there are some sample about how to access NvBufSurface . DeepStream SDK FAQ - #16 by bcao

Those urls didn’t help but thanks for trying.

SOLUTION
I needed to link the gpu mem to cpu mem like this:

    Npp32s* pHist[3] = {
        ( Npp32s* ) full_img_hist->surfaceList[0].dataPtr,
        ( ( Npp32s* ) full_img_hist->surfaceList[0].dataPtr ) + nLevels_3ch[0],
        ( ( Npp32s* ) full_img_hist->surfaceList[0].dataPtr ) + nLevels_3ch[0] + nLevels_3ch[1],
    };

    Npp32s* pHistCPU[3] = {
        ( Npp32s* ) full_img_hist->surfaceList[0].mappedAddr.addr[0],
        ( ( Npp32s* ) full_img_hist->surfaceList[0].mappedAddr.addr[0] ) + nLevels_3ch[0],
        ( ( Npp32s* ) full_img_hist->surfaceList[0].mappedAddr.addr[0] ) + nLevels_3ch[0] + nLevels_3ch[1],
    };

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.