Join Dan Gookin for an in-depth discussion in this video Recursion and directories, part of Code Clinic: C.
- Hello and welcome to Code Clinic. My name is Dan Gookin. Code Clinic is a course where a unique problem is introduced to a collection of lynda.com authors. In response, each author creates a solution by using their programming language of choice. You can learn several things from Code Clinic. Different approaches to solving a problem, the pros and cons of different languages, and some tips and tricks to incorporate into your own coding practices. This chapter's problem combines two concepts, recursion and accessing image data.
Recursion means to repeat something in a similar way. In programming, recursion means a function calls itself, like looking into a mirror to see the reflection of a mirror. Recursion solves many clever problems in a way a loop can't, especially for structures as diverse as a directory hierarchy or a chess board. JPEG files can contain additional image data stored as Exif or IPTC. Exif stands for Exchangeable image file format and it's a well documented standard.
If you have a digital camera or have taken photos with a newer cell phone camera, the image probably has Exif data available. Using a Macintosh, you can see this metadata information by opening the image in Preview, opening Tools, Show inspector, and selecting the Exif or IPTC tab. On Windows you can see metadata by right-clicking the image, selecting Properties, and the Details tab. You'll see things like Caption, Dimensions, Camera type, Color space, Exposure information, and other details.
Cell phones will also embed geographical location data identifying the longitude and latitude where the image was taken. The challenge is to look through a set of images and extract the caption information from the metadata, then organize the photos into alphabetical folders based on their caption. Sample images are included with this chapter's exercise files. As always, you might wanna take some time to solve this problem yourself. In the next few movies, I'll show you how I solved this challenge.
Dan introduces challenges and then provides an overview of his solutions in C. Challenges include topics such as statistical analysis, searching directories for images, and accessing peripheral devices.
Skill Level Beginner
Q: I am unable to access the Lake Pend Oreille data from outside the U.S.
A: A static copy of this data is provided here for lynda.com members outside of the U.S.