Hello,
I have created customized LUT with a different algorithm (using distortion correction coefficients) in C++. It works well when I test it in C++ but when I test that LUT in PSDK 7.1 . The results are totally different. I have created LUT similar to the format of TI LUT as shown below.
My question is ,
Is this the correct format of mesh LUT?
Is there any transformation (geometric or perspective) happening inside tivxVpacLdc Node? which is unwrapping the image rather than making it cylindrical as you can see in the resultant output image I am getting?
how VpacLdcNode is processing the LUT ?
this is the input image I have captured from camera for testing.
this is the desired output
The image I am getting from (app_single_camera) for LUT I have generated
Note: I am not downsampling my LUT so I kept the downsampling factor as 1
I have made the following changes in the app_single_camera to remove downsampling
#define LDC_TABLE_WIDTH (1280) #define LDC_TABLE_HEIGHT (944) #define LDC_DS_FACTOR (1) #define LDC_BLOCK_WIDTH (8) #define LDC_BLOCK_HEIGHT (2) #define LDC_PIXEL_PAD (1) table_width = 1280; table_height = 944; /* Mesh Image */ obj->mesh_img = vxCreateImage(obj->context,table_width, table_height, VX_DF_IMAGE_U32); vxCopyImagePatch(obj->mesh_img, &rect, 0, &image_addr, ldc_lut, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST); obj->mesh_params.mesh_frame_width = 1280; obj->mesh_params.mesh_frame_height = 944; obj->mesh_params.subsample_factor = 1
// make lut // find offset for x, y coordinate dx = fix - x; // distorted x - input x dy = fiy - y; // distorted y - input y // fractional weight_x = (8.0f * dx) & 0x7; weight_y = (8.0f * dy) & 0x7; qx = (int)dx; qy = (int)dy; xp = ((qx << 3) & 0xFFF8); // | (weight_x & 0x07); yp = ((qy << 3) & 0xFFF8); // | (weight_y & 0x07); //output data for one pixel val_encode = ((xp << 16) & 0xFFFF0000) | (yp & 0xFFFF); bilinear_table[y*outWidth + x] = val_encode; //print FILE *fp = fopen("LUT_TI.h","wt"); int i = 0; // make header fprintf(fp, "#ifndef ISXO16_UB9BA_Q1_DCC_H_\n"); fprintf(fp, "#define ISXO16_UB9BA_Q1_DCC_H_\n\n"); fprintf(fp, "#define ISXO16_UB9BA_Q1_DCC_CFG_NUM_ELEM (%du)\n\n", outWidth*outHeight*4); fprintf(fp, "#define ISXO16_UB9BA_Q1DCC_CFG \\\n{\\\n "); // store items for (i = 0; i<outWidth*outHeight-1; i++) { fprintf(fp, "0x%02x, ", bilinear_table[i] & 0xFF); fprintf(fp, "0x%02x, ", (bilinear_table[i] >> 8) & 0xFF); fprintf(fp, "0x%02x, ", (bilinear_table[i] >> 16) & 0xFF); fprintf(fp, "0x%02x, ", (bilinear_table[i] >> 24) & 0xFF); if(i%4 == 3) fprintf(fp, "\\\n "); } // last item fprintf(fp, "0x%02x, ", bilinear_table[i-1] & 0xFF); fprintf(fp, "0x%02x, ", (bilinear_table[i-1] >> 8) & 0xFF); fprintf(fp, "0x%02x, ", (bilinear_table[i-1] >> 16) & 0xFF); fprintf(fp, "0x%02x \\\n}\n\n#endif /* End of #ifndef ISXO16_UB9BA_Q1_DCC_H_ */\n", (bilinear_table[i-1] >> 24) & 0xFF); fclose(fp);
Kind regards,
Myrah Naeem