Hi,
I want to make conversion from uint8_t* to float32_t* (or float64_t*) in fastcv, uint8_t* is a RGB image, float32_t* is 4 times the size than uint8_t*.
can anyone tell me how to implement it, thanks~~
Here is the opencv code. (mat_float thats I want)
cv::Mat mat = cv::imread("/sdcard/Vms_out/1.jpg"); mat.convertTo(mat_float, CV_32FC3);
below code should work:
-- uint8_t *img = (uint8_t *)fcvMemAlloc(w*h, 16);
++ uint8_t *img = (uint8_t *)fcvMemAlloc(w*h, sizeof(uint8_t));
//ARGB->RGB gray
// fcvColorRGB888ToGrayu8 ((uint8_t*)rgb888, src_width, src_height, 0, (uint8_t*)img, 0);
-- float *I = (float *)fcvMemAlloc(w*h*4, 16);
++ float *I = (float *)fcvMemAlloc(w*h*4, sizeof(float)); // The size of float is 4.
for(int i=0; i<w*h; i++) {
*(I+i) = (float)(*(img+i))/255.0;
}
not sure why you call fcvColorRGB888ToGrayu8(), I think no need call it.
Thanks,
Xiaofeng
1. I use java to read the jpg file with ARGB, so should go flow: ARGB->RGB888->gray
2. I will scale down the gray image, the src should be aligned to 128 bit, so
uint8_t *img = (uint8_t *)fcvMemAlloc(w*h, 16);