📜 ⬆️ ⬇️

Industrial use of C ++ & OpenCV. Part 1: Problem Definition and Implementation Methods

In order not to overload this article, I will break it into 2 parts:

1. Statement of the problem and methods of implementation;
2. Software recognition and electronics.

Engineer


To begin with, I'm a novice engineer. As a student, I got a job as a programmer at a factory. The plant was engaged in the production of lacquer products. Simple: caps for seaming.
')
After a while, I received a task in my favorite for many free format. I was allowed to dream up on this topic and after a while provide my misl on this issue.

Fantasy


Considering the covers in the stack - it would seem that difficult? We take the nominal stack, put it next to the stack, which we consider and “by eye (by height)” we define 50 pieces or not 50.

It was not there. This method has already been used in production, and the error was, I tell you, + \ - 2 pieces.

Due to the process of manufacturing and cutting sealing gum, which is in each cover, the height could deviate by half a centimeter in both directions.



"Misley"


Immediately I remembered that I once dealt with OpenCV. I decided to use a bunch of OpenCV & C ++.

Several photographs were taken and several days spent trying to understand how ... Because of the constantly changing lighting, it was not clear how to select the interesting part from the overall picture. Then a closed “chamber” with a controlled environment was made in haste. By controlled environment, I mean the controlled location of the webcam and the light source.

A fluorescent lamp was found in the neighboring market, which, for our purposes, was ideal.



First success


Finally, exactly those pictures that we wanted began to turn out.



But then sleepless nights began, which flew by unnoticed ... There was more than enough enthusiasm. A few days / nights I got the first result. The “algorithmic” I came up with began to produce the correct values. After a preliminary demonstration, the senior management was given the go-ahead to continue this project.

The technological process of packaging products

This process consisted in the fact that after some manipulations by the “operator” she got into a thermo-packing machine, which covered the stack with film and baked at a high temperature for a fixed time.

The task was as follows: count the number of items in the stack before they are packed and output in the form understandable for the operator. In case there was “not 50” in the stack, no matter which way, the thermopack should not have passed this pile onto the package.

On the right, in an upright position, you can see a “nominal” pack with which everything was compared.



Above it can be seen that the lamp was installed parallel to the cradle, in which the product was placed for packaging.

The thermo-packaging machine was controlled by an Atmega8 based board, which was made by my colleagues long before my acquaintance with them.

Technical implementation
To perform the counting, it was decided to use FoxConn on Atome. Some amount of these miles has been bought.

image

Permission to launch a thermal pack and a visual display of the number of items was hung on the Arduino Nano.

image

Camera selected Logitech 920e:

image

An LED strip with a plexiglas lens was taken as a light.

In the second part I will describe the search algorithm, counting and in detail tell about electronics, which was developed and manufactured.

Source: https://habr.com/ru/post/253645/


All Articles