How do I display images taken with an Arduino in MATLAB?

20 views (last 30 days)
Hi,
I have an Arduino UNO (but once I get this working, I am switching to a much more complicated system) with an Arducam OV5642 camera shield attached. I have it taking a 640x480 photo every ~10 seconds and I want a way to show the images in real time (the photo taking can be slowed down if necessary). The relevant section of my arduino code is below (sorry about formatting, this is my first time posting code):
void loop() {
uint8_t temp = 0xff, temp_last = 0;
uint8_t start_capture = 0;
temp = Serial.read();
start_capture = 1;
Serial.println(F("ACK CMD CAM start single shot."));
myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK);
delay(800);
Serial.println("Start_capture=1");
if(start_capture == 1)
{
Serial.println("capture 'if' statement");
myCAM.flush_fifo();
Serial.println("capture 'if' statement 2");
myCAM.clear_fifo_flag();
Serial.println("capture 'if' statement 3");
//Start capture
myCAM.start_capture();
Serial.println("capture has been started");
delay(10000);
}
if(myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK))
{
myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK);
temp = 0;
Serial.println(F("ACK IMG"));
while( (temp != 0xD9) | (temp_last != 0xFF) )
//D9 is in hex=217 in decimal. FF=255
//according to the ArduCam Support, the head of the image data is 0xFF 9xD8
//and the end of the data is 0xFF 0xD9
{
temp_last = temp;
temp = myCAM.read_fifo();
Serial.write(temp);
delayMicroseconds(10);
}
Serial.println(F("ACK CMD CAM Capture Done."));
//Clear the capture done flag
myCAM.clear_fifo_flag();
start_capture = 0;
}
}
The serial.println statements are just checks I was using to figure out where it went wrong. As you can see in the code, the head of the image data is 0xFF 9xD8 and the end of the data is 0xFF 0xD9. This information was given to me by the ArduCam Support team on their GitHub forum. How do I receive the stream data in MATLAB and display it as an image? Thanks!
  3 Comments
Sukhmanpreet Singh
Sukhmanpreet Singh on 7 May 2019
Hello, Were you able to trigger capturing images using ultrasonic sensor? Please share the code if succesful.
shanmukh manikanta
shanmukh manikanta on 18 May 2019
Bro i need to display an image in matlab when i press a number in keypad connected to aruduino,.pls help me with this

Sign in to comment.

Answers (1)

sushmitha Veeralingam
sushmitha Veeralingam on 4 Jul 2019
I don't know much about arduino, but i am sure you can modify the code to save images to your PC. matlab can read images in a folder realtime and give outputs. i had a camera that could be sensed by matlab, so i wrote a python code to save the images to a folder and then used matlab for image processing.(improfile)

Categories

Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!