Lesson 1: Measuring Distance Using a Drone Photo

OVERVIEW

This lesson will introduce the user to photogrammetry, a fun concept that allows users to make calculations from aerial photography. We will be acquiring a photo that is taken autonomously with DroneBlocks, then use it to calculate distance and area.

"Photogrammetry is the science of making measurements from photographs, especially for recovering the exact positions of surface points. Photogrammetry is as old as modern photography, dating to the mid-19th century and in the simplest example, the distance between two points that lie on a plane parallel to the photographic image plane, can be determined by measuring their distance on the image, if the scale(s) of the image is known." (Wikipedia)

After taking a photo, students will then use their favorite image editing program (we love GIMP because it's free!) to measure pixel distances. Knowing the pixel distance and some basic information about the camera properties will allow us to calculate distances and areas--no need for old school measuring tape!

We feel that it's important to point out that while DroneBlocks makes it easy to capture this type of imagery, the real power is knowing what to do with it. There are many applications and interesting outcomes that can be accomplished with data acquired by drones!


OBJECTIVE

Students will:

  • Use DroneBlocks to create a mission that takes a nadir photo of any area of interest. An image example to work from will also be provided.
  • Examine camera properties for their specific drone to use in calculating distances and areas.
  • Use an image editing program to measure distance and/or area.
  • Verify calculations using Google Maps or measuring tape (old school!)
  • Develop proficiency in middle school and high school competencies that support mathematics standards.
  • Amplify standards recommended by ISTE*, such as Computational Thinking, Empowered Learning, and Innovative Design.

Remember! DroneBlocks is available both on iOS and as a Chrome App. This allows students to program and save their missions on the desktop, which can be accessed later by an iOS device in the field.

Let's get started!


PART 1: PLANNING

The first thing we will need to do is determine something in which we would like to measure. Choose something in the real world that may not be easy to collect measurements using a traditional measuring tape. Some examples include:

  • Roofline of your school or house
  • Distance from fence to fence in a yard
  • Distance from end to end of a track, soccer, or football field
  • Distance between buildings

Be creative! What can you come up with?

Make sure the distance between objects is not too far or you won't be able to fly your drone high enough to capture everything in a single photo. [Note: Yes, there are ways to stitch multiple photos together and we'll be covering that in a future lesson as it's quite a bit more involved.]

If weather conditions do not allow you to get outside to take a photograph, we have included a sample image to use here:


Click here for the full size photo. This photo was shot with our magnificent little DJI Spark using DroneBlocks. Our challenge was to find the distance between fences at the back of this property.


PART 2: CODING

Now that the area of interest is planned, let us program a basic DroneBlocks mission to take the aerial photo. You must takeoff to a specified altitude, angle the camera into position, take the shot, then land. Nadir is a term used in photogrammetry which describes the view directly below the camera, or aircraft. Remember this term when determining the angle of your camera.

Figure 1 shows a sample mission used to take an aerial shot of the fence line. Program your own mission, relative to your area of interest.


Figure 1: DroneBlocks mission for nadir aerial photo

You will notice that this mission makes use of variables at the top of the program. Variable blocks can be included to represent specific values are a great way to make missions more manageable. In the future you may want to take another nadir shot and it is simple to adjust your variable values. Perhaps you want to change the altitude of your shot or the distance flown to another location. Coding variables allows these changes to happen.

The mission in Figure 1 also utilizes the angle of the "pitch gimbal" block. The camera should point straight down to the nadir point. By default the camera is pointed straight forward, which is 0 degrees. To point the camera straight down, change the "pitch gimbal" value to -90 degrees.

Preview the mission. If you are using DroneBlocks on the desktop you will be asked to share your current location. "Allow" this access, as this location is used to create a home point for your mission. Figure 2 shows what this screen looks like.


Figure 2: Allowing DroneBlocks to access your location

Once your location is determined you will see a mission preview as shown in Figure 3. The mission will be drawn on a Google Map with the home location being Google's estimation of your computer's current location.

Figure 3: Map preview of DroneBlocks mission

If you'd like to change the home location simply drag and drop the home marker to a new location on the map. (Note: When using an iPad or iPhone, long tap to set your home point.)

The purpose of previewing missions is to verify your code behaves the way you expect and that you are not positioned to fly near potential obstructions. In Figure 3 you can see that the mission is programmed to fly over the edge of the school. Our students wanted to measure the roof of one side of the elementary school and this shows a preview of the mission they programmed.

Another useful feature of using the computer-based version of DroneBlocks is being able to click on a marker and view the latitude, longitude, and altitude at this location. Figure 4 shows what this looks like. You will notice that our waypoint is over the edge of the school, but the drone is at 275'. You can be confident that the drone will not run into the edge of the school at this altitude.

Figure 4: Desktop mission preview

Now that you have taken care of the DroneBlocks code and previewing the mission from your desktop go ahead and save your mission. You will need a Google account to login. After you login you will have the ability to save your mission with a title of your choice.


PART 3: FIELD MISSION

Now that your mission is coded, you can connect to your drone and load the previously saved mission on your tablet. We are not going to cover flight safety in this lesson as we've covered it extensively in previous courses. However, always review the safety precautions outlined in our Dronie Lesson if you are not familiar with regulations and review the pre-flight checklist.

With your drone powered up and DroneBlocks running on your device, review the mission one last time. Make sure:

  1. Your aircraft model name is at the the top right (such as Phantom 4, Mavic Pro, Spark, etc.)
  2. Your mission plan is programmed to do what you expect
  3. You can see your aircraft icon on the map at the right location
  4. Review all telemetry parameters before beginning your mission

Figure 5 shows a preview of a good satellite count, battery life for a short mission, and distance from home.

Figure 5: DroneBlocks pre-flight telemetry

Make sure your distance from home is "0 ft" or very close to 0. This the home location for your drone if you need to utilize the "return home and land" block. It is also the home location if you need to issue a manual return home sequence with your remote.

Now that everything appears finalized let us preview the mission as completed on the desktop. Figure 6 shows a mission preview from an iPad in the field. You should make note of your drone location (pink triangle) and all waypoints in which the drone will fly.

Figure 6: Mission preview for nadir shot

Click "Start Mission", "Confirm", and watch DroneBlocks do all the work!

If at any point you need to obtain manual control of your drone, there is an override sequence that will let you abort the autonomous mission. You can review the steps in this video tutorial:



PART 4: CALCULATING PIXEL DISTANCE

Now that you have acquired the nadir photo with DroneBlocks, you can complete the rest of this lesson from a desktop computer with either Photoshop or GIMP installed. The first thing you will want to do is download the photo from your drone's SD card to a folder on your computer.

If you would like to skip this step you can use the sample photo we provided. The goal is to measure a specified distance in your photo and find the length in pixels. In our case we will measure the distance between two fence lines on a property. Once we know the pixel distance we will calculate the ground sample distance (GSD) based on the camera's parameters. From these two values we will be able to determine the distance between the fence lines with reasonable accuracy.

Open your photo in Photoshop, GIMP, or other image editing program in which you are familiar. We are using GIMP since it is powerful program and free. Use the measuring tool to measure the number of pixels between the fence lines. Figure 7 shows an brief animation that walks through this process.

Figure 7: Using the measure tool in GIMP

From Figure 7 we can see that the distance between the fence is approximately 3,149 pixels. You are able to obtain a more precise number by zooming in, but for now a rough estimate is needed.


PART 5: CALCULATING GROUND SAMPLE DISTANCE

Now that we have the pixel distance we need to determine the ground sample distance (GSD) of each pixel. The ground sample distance tells us the distance between the center of two adjacent pixels on the Earth's surface. To calculate the GSD we need some specifics of the camera sensor on your drone. We have linked a spreadsheet of known sensor information for DJI cameras that will prove useful for the remainder of this lesson.

The spreadsheet contains a cell with the GSD pre-calculated, which enables you to type in the altitude of your DroneBlocks mission and see the GSD automatically calculated...But that's no fun! Let us get into some math and solve this for ourselves!

Figure 8 provides a visual representation of the camera sensor and field of view. Using the width of the camera sensor, focal length, and drone altitude the ground sample distance can be calculated.

Figure 8: Visual representation of nadir facing camera from drone.


The equation we will use to calculate the GSD is:

GSD = (sensor_width * altitude * 100) / (focal_length * image_width)

After calculating the GSD, determine the width (in meters) of the camera footprint with the following equation:

footprint_width = GSD * pixel_width_of_image

Start by calculating the GSD using the input values provided. Use the parameters from our DJI Spark sample image and camera sensor from our spreadsheet. Note: If you're using a different DJI drone, make sure you pull the appropriate values from the spreadsheet.

DJI Spark
sensor_width = 6.17 mm
focal_length = 4.55 mm
altitude = 50.4 m (this will vary based on your drone's altitude when the photo was taken)
image_width = 3968 pixels

Plugging the above values into the GSD equation, we now have:

GSD = (6.17 * 50.4 * 100) / (4.55 * 3968)

which equates to:

GSD = 1.7224 cm/pixel

The value of the ground sample distance of our photo is 1.7224 cm for every pixel. With this magic number we can easily calculate the distance footprint width of the entire photo.

footprint_width = 1.7224 cm/pixel * 3968 pixels

The pixel units cancel each other out and we are left with a distance of 6,834 cm. Let us divide this number by 100, which equates to 68.34 m. This gives us the footprint width of the entire photo, however we are interested in knowing the distance between the fences. This is where our "magic number" from GIMP or Photoshop becomes useful. Let us do the conversion again with the pixel distance between fences:

distance_between_fences = (1.7224 cm/pixel * 3149) / 100

Divide by 100 to convert from cm to m. The distance between fences is 54.24 m. For those who prefer to view this distance in imperial units we take the conversion of meters to feet:

1 m = 3.281 ft

and apply it to the metric distance:

54.24 m * (3.281 ft / 1m)

The meter units cancel out and we are left with 178 ft. The distance between the two fences is 178 ft. All done without a measuring tape or device!

A great deal of information has been covered in this lesson and we are going to be diving deeper into what can be done with drone imagery in the lessons that follow. We will cover calculating the camera field of view (FOV) and using this as another way to calculate distance. We will also be using this method to calculate the area of certain features in your photograph.


PART 6: EXTENSIONS

Now that you have the knowledge to calculate distances from drone imagery, design ways to extend student learning! Some ideas include:

  • Take photographs at different altitudes to observe how this impacts your equation results. You will find that the lower you are to the ground the higher resolution your GSD will be. For example, a GSD of 1 cm/pixel has a higher resolution than 2 cm/pixel.
  • Have students from your class lie on the ground, then use this method to measure their heights. How accurate is GSD in calculating small distances?
  • Another option is to measure the length of a car in your parking lot.
  • Try solving the equations with a rough pixel estimate (see Figure 7), then zoom in and gain a more precise pixel value. How great is the difference when using a more precise number?

Safety First! As we've discussed in other lessons, PLEASE don't fly directly over your students. Make sure your drone takes off and flies at least 25 ft away from observers, should anything go wrong in the air.

Complete and Continue