There are C ++ clients that stream frames from webcams to an HTTP server. Some cameras give flipped frames, and you need to programmatically analyze and flip the frame if it is flipped.

I know that this can be realized with the help of OpenCV, but the client is already quite loaded with both camera capture (vfw32) and network exchange and other bells and whistles, so it’s not very likely to be loaded with additional analysis, because most users are far from the most powerful machines.

Is it possible to perform such an analysis using GD tools in PHP?

  • Do you need to do all this analysis all the time? I would just make a tick "flip the picture for this camera" and ready. - KoVadim
  • This is already implemented using CSS / JS, but customers want automation not to click)) - Iceman
  • I ran across this problem and solved it very cunningly. I broadcast video from the cameras of laptops. And there also the picture is sometimes turned upside down. But it turned out that in most cases it is enough to know the device name and driver version. But do not forget that the user can simply flip the camera and need to decide, in this case, what to do? And the second is not always, even a group of people can determine if the picture is turned upside down (they say, Malevich’s square hung upside-down like that and no one noticed. Then trust these experts). - KoVadim
  • Well, I always know the driver version when initializing the camera class - this is usually the standard Windows driver. Of course, the version itself may differ. Is there any reference book on this topic (such as "drivers and their behavior on certain devices")? - Iceman
  • "Is it possible to perform such an analysis using GD tools in PHP?" This can be a painful operation for php, because you need to decode the frame to determine. Indeed, you may be doing this for a client once for a camera; clients may not notice a short-term high load. - Unick

1 answer 1

If it is possible to update the client, then you can add meta information to the image or 1 pixel in the lower right corner of a certain color, according to which it will be possible to determine the actual position of the image.
Often, even a person cannot determine the correct position of the image. enter image description here

I would look at the meta differences in the images from the camera, which renders the normal image from the camera, which gives an inverted one. Perhaps you can get by easily reading the beginning of the file.