Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Looking in the opencv source code we find in /modules/dnn/src/tensorflow/tf_importer.cpp in function parseTensor the following code:

  if (dims == 4)
   {
       int num = shape[0], channels = shape[1], height = shape[2], width = shape[3];
       int total = num*channels*height*width;
       for(int i_n = 0; i_n < shape[0]; i_n++) {
            for(int i_c = 0; i_c < shape[1]; i_c++) {
                for(int i_h = 0; i_h < shape[2]; i_h++) {
                    for(int i_w = 0; i_w < shape[3]; i_w++) {
                       int dst_i = channels*height*width*i_n + height*width*i_c + width*i_h + i_w;
                       int src_i = channels*height*width*i_n + i_c + channels*width*i_h + channels*i_w;

                       CV_Assert(dst_i < total);
                       CV_Assert(src_i < total);

                      dstData[dst_i] = data[src_i];
                   }
               }
           }
       }
 }

That is 4 tensors are transposed to account for the opencv format N X C X H X W. So the answer to the question is - the change in the data format is taken into account.