What Is Computer Vision and How It Works
Tags: machinelearning, ai
Published: 2021-04-23 09:44:00

---
title: What Is Computer Vision and How It Works
published: true
date: 2021-04-22 00:00:00 UTC
tags: machinelearning, ai, artificialintelligence
canonical_url: https://serokell.io/blog/guide-to-computer-vision
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/266pm3zxf2rszv7lswot.png
---

# Computer Vision

We perceive and interpret visual information from the world around us automatically. So implementing computer vision might seem like a trivial task. But is it really that easy to artificially model a process that took millions of years to evolve?

Read this post if you want to learn more about what is behind computer vision technology and how ML engineers teach machines to see things.

## What is computer vision?

Computer vision is a field of artificial intelligence and machine learning that studies the technologies and tools that allow for training computers to perceive and interpret visual information from the real world.

‘Seeing’ the world is the easy part: for that, you just need a camera. However, simply connecting a camera to a computer is not enough. The challenging part is to classify and interpret the objects in images and videos, the relationship between them, and the context of what is going on. What we want computers to do is to be able to explain what is in an image, video footage, or real-time video stream.

That means that the computer must effectively solve these three tasks:

- Automatically understand what the objects in the image are and where they are located.
- Categorize these objects and understand the relationships between them.
- Understand the context of the scene.

In other words, a general goal of this field is to ensure that a machine understands an image just as well or better than a human. As you will see later on, this is quite challenging.

## How does computer vision work?

In order to make the machine recognize visual objects, it must be trained on hundreds of thousands of examples. For example, you want someone to be able to distinguish between cars and bicycles. How would you describe this task to a human?

Normally, you would say that a bicycle has two wheels, and a machine has four. Or that a bicycle has pedals, and the machine doesn’t. In machine learning, this is called [feature engineering](https://manningbooks.medium.com/the-computer-vision-pipeline-part-4-feature-extraction-6343ef063588#:~:text=What%20is%20a%20feature%20in,distinguish%20objects%20from%20one%20another.).

![bicycle vs car](https://serokell.io/files/qv/qvpu2ppm.1st-1_(1).png)

However, as you might already notice, this method is far from perfect. Some bicycles have three or four wheels, and some cars have only two. Also, motorcycles and mopeds exist that can be mistaken for bicycles. How will the algorithm classify those?

When you are building more and more complicated systems (for example, facial recognition software) cases of [misclassification](https://www.researchgate.net/post/How_to_correct_the_misclassification_to_achieve_better_accuracy) become more frequent. Simply stating the eye or hair color of every person won’t do: the ML engineer would have to conduct hundreds of measurements like the space between the eyes, space between the eye and the corners of the mouth, etc. to be able to describe a person’s face.

Moreover, the accuracy of such a model would leave much to be desired: change the lighting, face expression, or angle and you have to start the measurements all over again.

Here are several common obstacles to solving computer vision problems.

### Different lighting

For computer vision, it is very important to collect knowledge about the real world that represents objects in different kinds of lighting. A filter might make a ball look blue or yellow while in fact it is still white. A red object under a red lamp becomes almost invisible.

![filters](https://serokell.io/files/jl/jlpbsc3i.2nd_(1).png)

### Noise

If the image has a lot of noise, it is hard for computer vision to recognize objects. Noise in computer vision is when individual pixels in the image appear brighter or darker than they should be. For example, videocams that detect violations on the road are much less effective when it is raining or snowing outside.

### Unfamiliar angles

It’s important to have pictures of the object from several angles. Otherwise, a computer won’t be able to recognize it if the angle changes.

![cat angles](https://serokell.io/files/na/na0615rk.3rd_(1).png)

### Overlapping

When there is more than one object on the image, they can overlap. This way, some characteristics of the objects might remain hidden, which makes it even more difficult for the machine to recognize them.

### Different types of objects

Things that belong to the same category may look totally different. For example, there are many types of lamps, but the algorithm must successfully recognize both a nightstand lamp and a ceiling lamp.

![lamps](https://serokell.io/files/d4/d4x91t3x.4th-min.png)

### Fake similarity

Items from different categories can sometimes look similar. For example, you have probably met people that remind you of a celebrity on photos taken from a certain angle but in real life not so much. Cases of misrecognition are common in CV. For example, samoyed puppies can be easily mistaken for little polar bears in some pictures.

It’s almost impossible to think about all of these cases and prevent them via feature engineering. That is why today, computer vision is almost exclusively dominated by deep artificial neural networks.

Convolutional neural networks are very [efficient at extracting features](https://www.sciencedirect.com/science/article/pii/S2405896317335346) and allow engineers to save time on manual work. [VGG-16 and VGG-19](https://towardsdatascience.com/top-10-cnn-architectures-every-machine-learning-engineer-should-know-68e2b0e07201) are among the most prominent CNN architectures. It is true that deep learning demands a lot of examples but it is not a problem: approximately 657 billion photos are uploaded to the internet each year!

## Uses of computer vision

![Uses of computer vision](https://serokell.io/files/ct/ct5tlj7b.Uses_of_computer_vision_(1).png)

Interpreting digital images and videos comes in handy in many fields. Let us look at some of the use cases:

- 

**Medical diagnosis.** Image classification and pattern detection are widely used to develop software systems that assist doctors with the diagnosis of dangerous diseases such as lung cancer. A [group of researchers](https://www.nature.com/articles/d41586-020-03157-9#:~:text=Bagci%20and%20his%20team%20have,rate%20that%20radiologists%20typically%20achieve.) has trained an AI system to analyze CT scans of oncology patients. The algorithm showed 95% accuracy, while humans – only 65%.

- 

**Factory management.** It is important to detect defects in the manufacture with maximum accuracy, but this is challenging because it often requires monitoring on a micro-scale. For example, when you need to check the threading of hundreds of thousands of screws. A computer vision system uses real-time data from cameras and applies ML algorithms to analyze the data streams. This way it is easy to find low-quality items.

- 

**Retail.** Amazon was the first company to open a store that runs without any cashiers or cashier machines. Amazon Go is fitted with hundreds of computer vision cameras. These devices track the items customers put in their shopping carts. Cameras are also able to track if the customer returns the product to the shelf and removes it from the virtual shopping cart. Customers are charged through the Amazon Go app, eliminating any necessity to stay in the line. Cameras also prevent shoplifting and prevent being out of product.

- 

**Security systems.** Facial recognition is used in enterprises, schools, factories, and, basically, anywhere where security is important. Schools in the United States apply facial recognition technology to identify sex offenders and other criminals and reduce potential threats. Such software can also recognize weapons to prevent acts of violence in schools. Meanwhile, some airlines use face recognition for passenger identification and check-in, saving time and reducing the cost of checking tickets.

- 

**Animal conservation.** Ecologists benefit from the use of computer vision to get data about the wildlife, including tracking the movements of rare species, their patterns of behavior, etc., without troubling the animals. CV increases the efficiency and accuracy of image review for scientific discoveries.

- 

**Self-driving vehicles.** By using sensors and cameras, cars have learned to recognize bumpers, trees, poles, and parked vehicles around them. Computer vision enables them to freely move in the environment without human supervision.

## Main problems in computer vision

![computer vision problems](https://serokell.io/files/r0/r0fh9e9r.Main_problems_in_computer_vision.png)

Computer vision aids humans across a variety of different fields. But its possibilities for development are endless. Here are some fields that are yet to be improved and developed.

### Scene understanding

CV is good at finding and identifying objects. However, it experiences difficulties with understanding the context of the scene, especially if it’s non-trivial. Look at [this image](https://static.life.com/wp-content/uploads/migrated/2015/03/150309-solar-eclipse-01-671x1024.jpg), for example. What do you think they are doing (don’t look at the URL!)?

You will immediately understand that these are children wearing cardboard boxes on their heads. It is not some sort of postmodern art that tries to expose the meaninglessness of school education. These children are [watching a solar eclipse](https://www.timeanddate.com/eclipse/box-pinhole-projector.html#:~:text=Tape%20the%20sheet%20of%20paper,the%20paper%20inside%20the%20box.). But if you don’t have this context, you might never understand what’s going on. Artificial intelligence still feels like that in a vast majority of cases. To improve the situation, we would need to invent general artificial intelligence (i.e. AI whose problem-solving capabilities possibilities are more or less equal to that of a human and can be applied universally), but we are [very far from doing that](https://www.forbes.com/sites/cognitiveworld/2019/06/10/how-far-are-we-from-achieving-artificial-general-intelligence/?sh=c75d7406dc4d).

### Privacy issues

Computer vision has much to do with privacy since the systems for face recognition are being adopted by governments of different countries to promote national security. AI-powered cameras installed in the Moscow metro [help catch criminals](https://www.hrw.org/news/2020/10/02/russia-expands-facial-recognition-despite-privacy-concerns). Meanwhile, Chinese authorities [profile Uyghur individuals](https://www.cnet.com/news/in-china-facial-recognition-public-shaming-and-control-go-hand-in-hand/) (a Muslim ethnic minority) and single them out for tracking and incarceration. When facial recognition is everywhere, everything you do can be subject to policies and shaming. AI ethicists are still to figure out the consequences of omnipresent CV for public wellbeing.

## Summing up

Computer vision is an innovative field that uses the latest machine learning technologies to build software systems that assist humans across different fields. From retail to wildlife conservation, smart algorithms solve the problems of image classification and pattern recognition, sometimes even better than humans.

Want to learn more about technologies? Continue reading our blog and follow us on [Twitter](https://twitter.com/serokell), [Medium](https://serokell.medium.com/), or [DEV](https://dev.to/serokell) for other exciting content.