title: How to set input with image for tensorflow-lite in c++?
body: <p>I am trying to move our Tensoflow model from Python+Keras version to Tensorflow Lite with C++ on an embedded platform.</p>
  
  <p>It looks like I don't know how set properly input for interpreter.</p>
  
  <p>Input shape should be (1, 224, 224, 3).</p>
  
  <p>As an input I am taking image with openCV, converting this to CV_BGR2RGB.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>
  std::unique_ptr&lt;tflite::FlatBufferModel&gt; model_stage1 = 
  tflite::FlatBufferModel::BuildFromFile("model1.tflite");
    TFLITE_MINIMAL_CHECK(model_stage1 != nullptr);
  
    // Build the interpreter
    tflite::ops::builtin::BuiltinOpResolver resolver_stage1;
    std::unique_ptr&lt;Interpreter&gt; interpreter_stage1;
    tflite::InterpreterBuilder(*model_stage1, resolver_stage1)(&amp;interpreter_stage1);
  
  TFLITE_MINIMAL_CHECK(interpreter_stage1 != nullptr);
  
    cv::Mat cvimg = cv::imread(imagefile);
    if(cvimg.data == NULL) {
      printf("=== IMAGE READ ERROR ===\n");
      return 0;
    }
  
    cv::cvtColor(cvimg, cvimg, CV_BGR2RGB);
  
    uchar* input_1 = interpreter_stage1-&gt;typed_input_tensor&lt;uchar&gt;(0);
  
   memcpy( ... );
  
  </code></pre>
  
  <p>I have issue with proper setup of memcpy for this uchar type.</p>
  
  <p>When I am doing like this, I have seg fault during working:</p>
  
  <pre><code>memcpy(input_1, cvimg.data, cvimg.total() * cvimg.elemSize());
  </code></pre>
  
  <p>How should I properly fill input in this case?</p>