In fact, it would be more correct to call “machine vision”, but I think it would be clearer if someone does not know that this is not security video surveillance, but recognition or measurement of something with the help of cameras. There are many tasks and areas where computer vision would be very popular and could be used everywhere, but in practice it is used very rarely.
I implemented several projects in this area to solve various tasks, specifically, this calculation and calculation of areas, product quality control, and different and in different industries such as: curly cutting and cutting of chipboard sheets, fiberboard, MDF, measurement of areas of animal skins for the production of products from skin, etc.
The task of calculating the area may seem rather complicated. If you approach strictly mathematically, then yes, for example, it is very easy to calculate the area of a square or rectangle by width and it’s ready if the triangle is a bit more complicated, but other curvilinear shapes can be very difficult.
My area calculation algorithm is so simple that it can be implemented without any libraries, etc. literally ten lines of code, in fact, this is the simplest motion detection with camera calibration only. The camera is rigidly fixed above the place where the products are fed, a background image is taken (without production), for example, a white table, the colors of the pixels are pushed into the array. Then a sample is put on the table or placed, for example, some kind of box. Next, a second picture is taken with the box, the colors of the second frame are written to another array and then the color values are compared, the number of different pixels is summed. Then this sample is measured by a tape measure, its area is entered into the program and the area of one pixel is calculated, i.e. the area is divided by the number of pixels. That's the whole calibration. Further, it is enough to submit any products, of any size and shape, the number of changed pixels will be determined, and multiplied by the area of one pixel found during calibration, I hope everything is clear. Moreover, the products can move, for example, on the conveyor, the area will be measured correctly, you only need to capture
frames to calibrate for movement, i.e. skip a few frames in which there are pixel changes along the edges of the camera in the direction of motion, so as not to capture products at the entrance and exit of the frame
')
This algorithm is 100% working and tested in practice. Of course, there are several points such as filtering optical noise, lighting, etc., strongly influencing the measurement error, but all this is successfully solved, both programmatically (auto-correction of color coefficients, etc.) and hardware-cameras that can immediately filter noise, physically in production conditions, stable lighting in the closed part where the camera is installed is easily realized.
In practice, the error is less than 1% for fixed production and up to 3% for mobile.
There are many developments, for example, Open CV (
Open Computer Vision ). By the way, on Habré there is a
post about the history of this library, there are many systems of recognition of images, numbers, faces, etc., all this is ready and can be used.
But in practice, very little used solutions with computer vision. But what is most interesting is the fact that all these tasks are still solved in different, but very different, ways, with the help of other equipment, and much more expensive. Most of these systems I have implemented have been installed in enterprises because of the failure of this equipment for the calculation, the high cost of repair or the purchase of a new one. I did not see this equipment in action, I saw only the number of sensors, mechanics, electronics, etc. According to customer feedback, the old systems worked worse, slower, and some even with a larger margin of error. Moreover, the cost of such equipment with at least 4 zeros in USD, despite the fact that the system with "computer vision" is much cheaper, and everything costs completely with a computer, camera and software less than $ 1000, you can even invest in $ 500. There is a ready solution. High power of the computer is not needed, it will work without brakes even on the cheapest netbook. In addition to the area, you can determine the colors of products, surface defects, defects / battle and much more.
Recently I read on “
Hookrae Crusher Programmer ” about the approaches of programming and especially the design of software solutions and I want to use this example to tell about Crutches when implementing a similar project by another team. I had a chance to talk with the programmers of this team and I was very surprised what they were doing there. Algorithms are used strictly mathematical, a bunch of third-party libraries, higher mathematics, not to mention OOP with hundreds of classes, etc. To determine the types of shapes, coordinates, positions, etc. use OpenCV (about which I wrote above), and the area is calculated by complex formulas, on the sides, angles, curvature, etc. As a result, the product turned out to be very crooked, it requires a lot of computer power and in practice it works very badly, long and complex settings are needed for a specific type of product, and much more not to mention an error that reaches 10%. About the very OpenCV I do not want to speak too much, because This is a separate topic, I’ll just say that many things worked very poorly there, in any case, they worked poorly or didn’t work at all before, it was about 5 years ago, when it was still Intel, I think that’s why Intel refused it and dropped it in Open Source. But what struck me most was the fact that some programmers do not even allow the thought that the solution can be much simpler and more reliable. It was a small company, but many well-known companies that hire such programmers also sin.
As a result, many projects fall apart, deadlines are delayed and the worst is that curves and buggy products are obtained. And very often, not because the bad code or programmers, but because the bad algorithms and the bad approach to the design initially.
I led this example to the fact that now more and more programmers instead of simplifying everything — complicate things, use OOP, design patterns, etc. where it is generally not needed at all and then when it is still or not at all. Light heads are so crammed with categories, objects and classes that many simply can no longer think differently. Abstraction is needed not to complicate things, but to simplify the system, primarily to simplify understanding and look at it from the other side. Another problem is that many people choose the wrong libraries and the wrong technologies. I’m especially scared by programmers who, after reading new-fashioned books, and having attended several seminars on PLO, consider themselves professionals and begin to tell how to do the “right” things, etc., they can build huge UML diagrams, model something, write some then abstract (empty) classes, without any functionality, etc. at the same time, something that really works cannot be thought out and done. Most often, such people are the real “Kostyl programmers” who generate Kochyl 'projects with Kostyl architecture, something like “
Astronauts of Architecture ” (D. Spolsky). Of course, it may seem like a lot to newbies, etc. but this is usually not the case, because most of these projects fail, in other cases they are heavily stretched, as long as the customer is ready to pay for the non-working product, but in the end it is still falling apart or is being rewritten by another team. There are of course exceptions and good products are obtained, sometimes bad code is also to blame, with good algorithms and tools, but this happens much less often, at least in my, not small, practice, there were very few such cases.
OOP would not want to touch on of course, because I'm afraid there will be a very long and unnecessary discussion, this is a separate topic, I agree with the authors of this famous discussion in many respects:
Why object-oriented programming failed . OOP and, in particular, OO Design from top to bottom, is applicable only in very large and very complex projects, but not all, there are very few such projects. And the design in most cases, you need to start from the bottom up, with basic functionality and basic prototypes, because after receiving the first results, everything can change radically, the subject area and the essence of the task will become more understandable, not to mention the “bug features” (many good technologies emerged due to bugs that later became excellent “features”). And of course the most important thing is to choose the right algorithm for solving the problem. If the project is very complex, and does not fit in the head, then in most cases OOP, UML and design systems, modeling, etc. anyway, most likely they will not solve the problem and will not simplify anything, but rather even complicate it. Therefore, to create a very complex, but really working system, it is better to divide it into several projects, directions or libraries and minimize data exchange flows between the whole economy. Remember that all ingenious is simple.
I think that “Computer Vision” is little used in practice, because there are no good industry solutions and good implementations that could be easily installed and configured without the help of experts in this field. And those that are - either too expensive or not promoted, and very few people know about them.