0

Using MATLAB I am capturing an image from a webcam. I want to extract the date and time of the captured image. How can I do that?

This is my code::

vid = videoinput('winvideo', 1, 'RGB24_640x480');
for i=1:10
    img=getsnapshot(vid);
    fname=['image' num2str(i)];
    imwrite(img,fname,'jpg');
    pause(3);
end
Adriaan
  • 17,741
  • 7
  • 42
  • 75

1 Answers1

1

A webcam probably doesn't have the built-in clock, therefore you won't be able to extract the date-time information from the captured image.

Instead, use one of the built-in Matlab functions, e.g.

datestr(now, 'yyyy-mm-dd hh:MM:ss.fff')

will return the current timestamp in the ISO 8601-like format.

The functions you may want to use:

texnic
  • 3,959
  • 4
  • 42
  • 75
  • Does that "datestr" function stores the date and time with the captured image? – PramodHegde Apr 12 '16 at 20:48
  • @Pram_Haunter, no, it only formats it the way you want. There is no built-in Matlab function to save metadata (EXIF) in JPEG files. However you can do it using [exiftool](https://en.wikipedia.org/wiki/ExifTool) as mentioned in [another thread](http://stackoverflow.com/a/9058583/674976). – texnic Apr 12 '16 at 20:59