C++ Dereferencing char-Pointer (image array) is very slow -
i have trouble getting fast access unsigned character array.
i want copy bgrabgra....bgrabgra.... linewise coded image array opencv-version uses 3 layers. code below works fine slow (around 0.5 seconds 640*480 image). pointed out dereferencing operator * makes slow. have plan how fix this? (hint: byte unsigned char)
// run thorugh pixels , copy image data (int y = 0; y<imheight; y++){ byte* pline= vrim->mp_buffer + y * vrim->m_pitch; (int x = 0; x<imwidth; x++){ byte* b= pline++; // fast pointer operation byte* g= pline++; byte* r= pline++; byte* a= pline++; // (alpha) byte bc = *b; // slow! byte gc = *g; // slow! byte rc = *r; // slow! } }
thanks!
shouldn't - there no way taking 0.5sec 640x480 unless doing on 8086. there other code aren't showing? destination memory doesn't go anywhere
ps take @ cvcvtcolor() uses optimized sse2/simd instructions
Comments
Post a Comment