Opencv imread

How can I use imread to read image from and card on he lychee board?please help.

  • The below is a sample, that read jpeg from SD and then re-write copied image into SD.

    You may use popular image Lenna as below. The size is 400 x 225.

    #include <Arduino.h>
    #include <Camera.h>
    #include <opencv.hpp>
    #include "SdUsbConnect.h"

    using namespace cv;

    SdUsbConnect storage("storage");

    void setup() {
    Serial.begin(9600);
    pinMode(PIN_LED_YELLOW, OUTPUT);
    digitalWrite(PIN_LED_YELLOW, HIGH);
    // SD & USB
    Serial.print("Finding strage..");
    storage.wait_connect();
    Serial.println("done");

    Mat image = imread("/storage/lena.jpg", IMREAD_COLOR);
    if (!image.empty()) {
    imwrite("/storage/lena_copy.jpg", image);
    digitalWrite(PIN_LED_YELLOW, HIGH);
    }
    }

    void loop() {

    }


  • In reply to Okamiya Yuuki:

    The below is a sample to display jpeg image using LCD.

     

     

    #include <Arduino.h>
    #include <Camera.h>
    #include <LCD.h>
    #include <opencv.hpp>
    #include "SdUsbConnect.h"

    using namespace cv;

    SdUsbConnect storage("storage");
    LCD lcd;
    static uint8_t work_buf[BYTE_PER_PIXEL_YUV * 640 * 480];
    void setup() {
    Serial.begin(9600);
    pinMode(PIN_LED_YELLOW, OUTPUT);
    digitalWrite(PIN_LED_YELLOW, HIGH);
    // SD & USB
    Serial.print("Finding strage..");
    storage.wait_connect();
    Serial.println("done");

    Mat image = imread("/storage/lena.jpg", IMREAD_COLOR);
    if (!image.empty()) {
    imwrite("/storage/lena_copy.jpg", image);
    digitalWrite(PIN_LED_YELLOW, HIGH);
    }

    lcd.begin(work_buf, image.cols, image.rows);
    lcd.clear();
    lcd.BGR2YUV(image.data, work_buf, image.cols, image.rows);
    }

    void loop() {

    }