MATLAB Answers

0

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

Asked by Joshua Werblin on 14 Apr 2017
Latest activity Commented on by shanmukh manikanta on 18 May 2019 at 6:26
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

Hello, Im getting same problem as yours. Did u get any solution for this? Actually i want to trigger my arducam OV5640 to take picture by an ultrasonic sensor and then upload that picture to a MATLAB program. Any idea how can I do that?
Hello, Were you able to trigger capturing images using ultrasonic sensor? Please share the code if succesful.
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.

0 Answers