NatCam Tutorial Series 3: Photos

Lanre Olokoba
Jul 10, 2017 · 2 min read

Hi guys. Welcome to part 3 of the NatCam Tutorial Series. In this part, we will be discussing photo capture with NatCam. First, make sure you have gone over part 1 and part 2.

Capturing a Photo

Photo capture is one of the most essential features of NatCam. NatCam provides this functionality through the CapturePhoto method:

Let’s walk through a simple example utilizing photo capture.


PhotoCam Example

Starting with a blank Unity project, import NatCam. Now let us create a RawImage that covers the whole screen; I’ll call mine ‘Preview’

Now, let us create a PhotoCam script. We will check for a double tap on the screen, and if we get one, we will capture a photo.

Let’s plug it all in in the Editor.

Build and Run!

Memory Management and Best Practices

I would like to bring the very important issue of memory management to your attention. It is quite often overlooked, but Texture objects are not CLR objects, as a result, garbage collection will not free their resources. If you find yourself running out of memory after taking a few pictures, it is because you must free each picture from memory when you are done with it. To do so, simply call:

That’s it for this tutorial. In the next tutorial, I will discuss accessing the preview data in realtime with NatCam. See you next time!

— Lanre Olokoba.


NatCam is a cross-platform camera API for the Unity Engine. Get NatCam here: NatCam.

Lanre Olokoba

Written by

Trying to better understand life through philosophy, mathematics, and computer science. Proprietor @ NatSuite API's. Founding member @ Homedeck.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade