I want to talk about a couple of interesting ways to encode data - encoding in the form of a picture and embedding them into an existing picture. I experimented with the PNG format because it uses lossless compression and is supported in browsers in the canvas element. I am interested in JavaScript, so the implementation will be written in it. The code is implemented as a JS library and posted on GitHub under the MIT license.
The first encoding option is to generate a new picture based on arbitrary data. To do this, each byte of data is recorded sequentially in the RGB channels of the PNG picture, while the alpha channel is not touched, since when the alpha channel changes, the RGB colors partially change when unloading from canvas to PNG. In this variant, WIDTH * HEIGHT * 3 bytes of data can be packed in PNG. When encoding text, the image size is smaller than the source text, since Deflate compression is applied to the data.
// encode file to PNGasPNG.encode(file).then(blob=>{// encoded blob});// decode file from PNGasPNG.decode(file).then(blob=>{// decoded blob});
Some time ago I found a curious device on the Internet - a keychain powered by a radioisotope of hydrogen (tritium). The principle of operation there is as follows: there is an isotope in the sealed cavity, the inner part of the cavity is covered with a phosphor, which glows when exposed to electrons emitted as a result of beta decay of tritium. The half-life of tritium is 12 years, which ensures the continuous glow of the phosphor for many years.
I was inspired by this idea and somewhere in 2013, the idea appeared to make a keychain beacon so that it glowed and was visible in the dark for a long time. You can use it for keys, you can use it for something else, I was interested in the idea. However, I decided to use not a radioactive element, but an electric circuit with an ordinary LED. It remained to make the LED glow for many years without replacing the batteries, while maintaining the size of the keychain.
More recently, OpenCV introduced an API for detecting anthropometric points of the face. There is a good article on using the Facemark API at Learn OpenCV. A good implementation of the search for such points is in the dlib library, but sometimes you want to limit yourself to one library, especially when it comes to porting code to mobile devices or a browser (by the way, OpenCV supports compilation in WebAssembly). Unfortunately, face point search algorithms use models of a sufficiently large size (68 points ~ 54 MB), and the size of the downloadable code per client may be limited. The dlib library has a pre-trained model for 5 points (5.44 MB), but for OpenCV there is no such model, and there is not even support for such a model, at the moment models for 68 and 29 points are supported. The 5-point model can be used to normalize faces on the client. Below I will describe the process of learning your own model of a small size for 5 points.
The authors of the article give an example of the implementation of this algorithm in C with a pre-trained classifier for face detection. Recently, an implementation of the PICO algorithm in JS has appeared, but it does not implement the invariance of turning the image (or tilting the head to the left/right). This is the shortcoming I decided to fix.
To implement the rotation invariance, it is necessary to run the algorithm several times for the image rotated at several angles. But since the algorithm works with pixels, and not an integral image, you can not perform a resource-intensive image rotation operation, but simply read the desired pixels using a rotation matrix.
The revision included:
implementation of invariance to turn;
re-trained classifier of persons;
a more productive method for converting the RGBA image to grayscale;
When the task appears to transmit some code by audio, the classic solution is DTMF codes. DTMF is a two-tone multi-frequency signal used to dial a phone number. However, the actual application of this technology is much wider.
The signal format is the sum of two sinusoidal signals of certain frequencies. DTMF symbols are encoded by the following frequencies:
The problem with the TL-WR841N router (v9 in my case) is that there’s only 4MB of flash memory and after the OpenWRT firmware, there’s only about 300KB left for personal use, which is not enough to install OpenVPN. The solution to this problem is in the post OpenWrt + VPNclient for a router with 4mb ROM, but several years have passed and scripts require changes.
In the tasks of automatic processing of images of faces, the question of finding and normalizing (aligning) the image of a face in a photo or video stream often arises. Alignment usually involves rotating, zooming, and cropping the part of the photo of interest. On the web, you can find examples for implementing this function in Python or C/C++ using the OpenCV computer vision library. Here I will give two examples of the implementation of this function in JavaScript for NodeJS and for running in a browser on pure JS.
Today was the official release of Linux Deploy 2.0, which includes many new developments that have been conducted over the past year. Not everything could be realized from what was conceived for one reason or another, it’s time to figure out what exactly has changed and how to live with it. For more details, see the project page.
Linux Deploy supports automatic installation and configuration of some of the most common desktop environments. Version LD 2.0 retains support for XTerm (full-screen terminal), LXDE, Xfce, and MATE environments. These environments are in almost all supported LD distributions, they are not very demanding on resources and can work without graphical acceleration. However, you can start other desktop environments manually. To do this, in the LD settings, select the “Other” desktop environment and execute the “Configure” command. After that, you need to connect to the container, install the packages of the desired environment of the desktop, and under the user (by default - android) edit the file ~/.xsession, prescribing the command to start the working environment.