cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Observer
Observer
614 Views
Registered: ‎10-21-2018

xfOpenCV library: HOG descriptor Output

HOG function in xfOpenCV library documentation says that output format descriptor must be XF_32UC1 (32 bits unsigned). Also, that output feature vector will be in the fixed point type Q0.16. How should I interpret this information, if they are talking about the same output vector?

Anyone has worked with the output vector of the HOG function? I am trying to link this output with python scikit-image library for pedestrian detection,  but I can´t understand how to handle the output. Thanks.

0 Kudos
3 Replies
Highlighted
Moderator
Moderator
579 Views
Registered: ‎05-27-2018

Hi @kiniman_2000 ,

    Safely use the 32 bits unsigned data type 'XF_32UC1' for the output vector. You can refer to the test beach to see that the data is loaded using OpenCV function and transfer into xf:Mat class, then perform the hog_descriptor_accel function. The XF_INPUT_TYPE was defined in the xf_types.h. 

    Also, The feature vector will be in the fixed point type Q0.16 in the HLS implementation which don't inpact how you manage your code on the high level. Some of the Function Parameter in xfopencv uses the Q format which will be clearly declared in UG1233.

hop function
void hog_descriptor_accel(xf::Mat<XF_INPUT_TYPE, XF_HEIGHT, XF_WIDTH, XF_NPPC1> &inMat, xf::Mat<XF_32UC1, 1, XF_DESC_SIZE, XF_NPPC1> &outMat) { xf::HOGDescriptor <XF_WIN_HEIGHT,XF_WIN_WIDTH,XF_WIN_STRIDE,XF_BLOCK_HEIGHT,XF_BLOCK_WIDTH,XF_CELL_HEIGHT,XF_CELL_WIDTH, XF_NO_OF_BINS,XF_DESC_SIZE,XF_INPUT_COLOR,XF_OUTPUT_MODE,XF_INPUT_TYPE,XF_32UC1,XF_HEIGHT,XF_WIDTH,XF_NPPC1,XF_USE_URAM>(inMat,outMat); }
Test bench
////////////////// HLS TOP Function Call ////////////////////////
static xf::Mat<XF_INPUT_TYPE, XF_HEIGHT, XF_WIDTH, XF_NPPC1> inMat(img.rows,img.cols);
inMat.copyTo(img.data);
#if REPETITIVE_BLOCKS
static xf::Mat<XF_32UC1, 1, XF_DESC_SIZE, XF_NPPC1> outMat(1,dim_rb);
#elif NON_REPETITIVE_BLOCKS
static xf::Mat<XF_32UC1, 1, XF_DESC_SIZE, XF_NPPC1> outMat(1,dim_nrb);
hog_descriptor_accel(inMat,outMat);
#endif

   Sorry for the delay of the respond.

Thanks,

Wen

-------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------
如果提供的信息能解决您的问题,请标记为“接受为解决方案”。
如果您认为帖子有帮助,请点击“奖励”。谢谢!
-------------------------------------------------------------------------------------------------
0 Kudos
Highlighted
Moderator
Moderator
528 Views
Registered: ‎11-21-2018

Hi @kiniman_2000 

Do you have any update on this? 

Regards, 

Aoife
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Highlighted
Contributor
Contributor
366 Views
Registered: ‎08-06-2014

Hi,  I'm confused about this code in testbench:

#if REPETITIVE_BLOCKS
	int dim_rb = (total_no_of_windows*XF_NODPW)>>1;
	int no_of_descs = dim_rb;
#elif NON_REPETITIVE_BLOCKS
	int dim_nrb = (nohb_tb*novb_tb*XF_NOBPB)>>1;
	int no_of_descs = dim_nrb;

Why ">>1"? 

I guess maybe the output of hog_descriptor_accel is organized as two Q0.16 combined into one ap_uint32_t, as I see both REPETITIVE_BLOCKS and NON_REPETITIVE_BLOCKS convert ap_uint32_t to two number:

#elif REPETITIVE_BLOCKS
	OUT_T1* output1 = (OUT_T1*)malloc(dim * sizeof(OUT_T1));

	ap_uint32_t temp;
	int high=15,low=0;

	int cnt=0;
	for(int i=0;i<(dim_rb);i++)
	{
		temp=outMat.read(i);
		high=15;low=0;
		for(int j=0;j<2;j++)
		{
			output1[i*2+j]=temp.range(high,low);
			high+=16;
			low+=16;
			cnt++;
		}
	}
#elif NON_REPETITIVE_BLOCKS   // Reading in the NRB mode and arranging the data for comparison
	float out_fl_tmp[dim_expand];
	int tmp_cnt=0;

	for(int i = 0; i < dim_nrb; i++)
	{
		for(int j=0;j<2;j++)
		{
			out_fl_tmp[((i<<1)+j)] = (float)((output[i]>>(j<<4))&operatorAND)/(float)65536.0; 
		}
	}

that makes the number of dimension should be ">>1".

0 Kudos