c++ - Macro or inline function to iterate over OpenCV matrices -


does opencv provide macro or function iterate on matrices without knowing channel depth?

eventually implemented myself, wonder whether available somewhere within opencv source, or if there better way achieve same result?

#define cv_eval(src,i,j,c,dst)                                                                                                   \     if(src.depth() == cv_8u) {                                                                                                       \         dst = ((uchar*)(src.data))[ i*src.step1()+ j*src.channels() + c];         }                                                                                                                                                            \   else if(src.depth() == cv_8s) {                                                                                              \         dst = ((schar*)(src.data))[ i*src.step1()+ j*src.channels() + c];         }                                                                                                                                                            \   else if(src.depth() == cv_16u) {                                                                                           \         dst = ((ushort*)(src.data))[ i*src.step1()+ j*src.channels() + c];        }                                                                                                                                                            \   else if(src.depth() == cv_16s) {                                                                                           \         dst = ((short*)(src.data))[ i*src.step1()+ j*src.channels() + c];         }                                                                                                                                                            \   else if(src.depth() == cv_32s) {                                                                                           \         dst = ((int*)(src.data))[ i*src.step1()+ j*src.channels() + c];         }                                                                                                                                                            \   else if(src.depth() == cv_32f) {                                                                                           \         dst = ((float*)(src.data))[ i*src.step1()+ j*src.channels() + c];         }                                                                                                                                                            \   else if(src.depth() == cv_64f) {                                                                                           \         dst = ((double*)(src.data))[ i*src.step1()+ j*src.channels() + c];           \     }                                                                                                                                                            \   else {                                                                                                                                                 \     cv_assert(false);                                                                                                                        \     } 


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -