cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
374 Views
Registered: ‎07-05-2019

trying to read Sobel filter source code matrix values

from Sobel source code, in the top.cpp file

void sobel_filter_core(YUV_IMAGE &src, YUV_IMAGE &dst, int rows, int cols, int kappa, int delta_t)
{

Y_BUFFER buff_A;
Y_WINDOW buff_C;

//----For CBCR Buffering---//
Y_BUFFER CB_LB;
Y_WINDOW CB_WB;

Y_BUFFER CR_LB;
Y_WINDOW CR_WB;
//-------------------------//
unsigned char count;
count =0;


for(int row = 0; row < rows+1; row++){
#pragma HLS LOOP_TRIPCOUNT MAX = 1081
for(int col = 0; col < cols+1; col++){
#pragma HLS LOOP_TRIPCOUNT MAX = 1921
#pragma HLS loop_flatten off
#pragma HLS dependence variable=&buff_A false
#pragma HLS PIPELINE II = 1

YUV_PIXEL tempx;
unsigned char temp;
unsigned char temp_cb; //temp chroma
unsigned char temp_cr; //temp chroma

//Line Buffer fill
if(col < cols){
buff_A.shift_down(col);
temp = buff_A.getval(0,col);

CB_LB.shift_down(col); //CRCB
temp_cb = CB_LB.getval(0,col); //CRCB

CR_LB.shift_down(col); //CRCB
temp_cr = CR_LB.getval(0,col); //CRCB
}
//There is an offset to accomodate the active pixel region
//There are only MAX_WIDTH and MAX_HEIGHT valid pixels in the image
if(col < cols && row < rows){
YUV_PIXEL new_pix;
src >> new_pix;
tempx = new_pix;
buff_A.insert_bottom(tempx.val[0],col);

CB_LB.insert_bottom(tempx.val[1],col); //CRCB

CR_LB.insert_bottom(tempx.val[2],col); //CRCB
}

//Shift the processing window to make room for the new column
buff_C.shift_right();

CB_WB.shift_right(); //CRCB
CR_WB.shift_right(); //CRCB

//The Sobel processing window only needs to store luminance values
//rgb2y function computes the luminance from the color pixel
if(col < cols){

buff_C.insert(buff_A.getval(2,col),2,0);
buff_C.insert(temp,1,0);
buff_C.insert(tempx.val[0],0,0);


CB_WB.insert(CB_LB.getval(2,col),2,0); //CBCR
CB_WB.insert(temp_cb,1,0); //CBCR
CB_WB.insert(tempx.val[1],0,0); //CBCR

CR_WB.insert(CR_LB.getval(2,col),2,0); //CBCR
CR_WB.insert(temp_cr,1,0); //CBCR
CR_WB.insert(tempx.val[2],0,0); //CBCR

}
YUV_PIXEL edge;

//The sobel operator only works on the inner part of the image
//This design assumes there are no edges on the boundary of the image
if( row <= 1 || col <= 1 || row > (rows-1) || col > (cols-1)){
edge.val[0] = 0;
edge.val[1] = 128;
edge.val[2] = 128;
} else {

//Sobel operation on the inner portion of the image
edge = sobel_operator(&buff_C,&CB_WB,&CR_WB, kappa,delta_t);//Pass by reference
count = count+1;
}

//The output image is offset from the input to account for the line buffer
if(row > 0 && col > 0) {
dst << edge;
//s
}
}
} printf("FUNCTION CALLED %d TIME \n",count);
std::cout << dst[2] << " ";
}

Error:

../../../../FILES/top.cpp:200:19: error: no match for 'operator[]' (operand types are 'YUV_IMAGE {aka hls::Mat<1080, 1920, 4096>}' and 'int')
std::cout << dst[2] << " ";

I want to check my final image matrix values but it keeps failing..

I have tried std::cout << dst[2][2][0]<< " "; 

and std::cout << dst[2,2,0]<< " "; 

but everytime I get the same error.

I would really appreciate if someone can tell me how to print my matrix values.

0 Kudos
1 Reply
florentw
Moderator
Moderator
269 Views
Registered: ‎11-09-2015

Hi sneha.chand@htic.iitm.ac.in 

I do not think you can. You should not see dst as an array but just like a pointer. It will output the pixel one by one.

If you want to look at the pixels value you need to do it from the test bench not from the function itself


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos