Piero V.

Zbar, GTK and Python 3

Last week, we had Hackweek at Tor. Instead of doing what we usually do, we worked on small Tor-related projects for 5 days. I chose to work with intrigeri and boyska from Tails to help them improving the pluggable transports on Tails.

There are several ways to get Tor bridges. One is requesting them to BridgeDB through email. The answer contains the bridge lines both as text and in a QR code. So, the first objective of our Hackweek team was to create a proof-of-concept to load these QR codes through a webcam.

Tails’s connection wizard is written in Python. A trivial approach is capturing frames from the webcam with OpenCV, then decoding them with pyzbar. This would have worked, but Tails is a live system, and an OpenCV installation requires a lot of space.

I soon discovered that OpenCV is the de facto way to deal with webcams in Python. I have tried some other alternatives, but they did not work. I have also tried to use a low-level approach based on the V4L2 API. But dealing with the conversion of color spaces and creating a generally reliable solution is burdensome. … [Leggi il resto]

OpenCV and time lapses

After buying my Pixel 4a, I decided to take a picture of a poplar near my home every day. I did this for one year, and I created a time lapse. But I will not publish it here because it would reveal where my home is 😜️.

Methodical is not enough

With time lapses, you usually keep your camera still, but this was not an option in my case. Therefore, I tried to be methodical in taking the various pictures.

I used a sewer cover as a point to shoot the photo and a telephone pole as a reference (its tip is close to the upper-left corner in every picture).

Still, the results were varied, but luckily OpenCV came to the rescue.

Homography matrices

We could say that my scenario is like capturing the same scene with different cameras. Therefore, we can compute the homography matrix to reproject one image to the previous one.

And OpenCV has a very handful function to do so: findHomography. It takes the coordinates of corresponding points as inputs, and it returns a 3-by-3 matrix as output.

If you are using Python, you must pass the points as two NumPy matrices. Both must have the same shapes: a row for each pair and two columns with the coordinates. The point at the ith row of the first array must correspond to the point at the ith row of the second array. … [Leggi il resto]

PyElas

Recently, I started experimenting with stereo vision.

It is a technique to produce depth maps using images captured by close positions. Then, with these maps, it is possible to create 3D representations.

The core of this workflow is the matching algorithm, which takes pairs of post-processed images and creates a “disparity” map. The disparity is the distance between a point in the two images. Depth and disparity are inverses, so it is easy to switch from one to the other.

OpenCV contains some stereo matching algorithms, but they produced a lot of noise. So I looked for another library, and I found libelas.

It is a GPLv3 C++/MATLAB library with many parameters to tune, but I could not find a Python version. My options were to switch to C++ or to port it by myself. I chose the latter, hoping that also others can benefit from it 🙂️.

Long story short, I published my first package on PyPI: PyElas.

How to use it

You can install it using pip. Then you just have to do this: … [Leggi il resto]

Una Fenice che torna al passato

Questione di desideri…

15 anni fa, desideravo diventare uno sviluppatore web: ero affascinato da questo mondo e avrei voluto farne parte anche io. Un po’ alla volta ho imparato a usare gli strumenti necessari e creai il mio primo sito.

12 anni fa, ho realizzato che non bastava fare delle pagine web e basta, ma dovevano avere uno scopo. Ho anche realizzato che fare sia il contenuto, che tutto il sistema per gestirlo era un lavoro enorme e le mie competenze non ne erano all’altezza. Sono quindi passato a dei CMS: Flatpress, DokuWiki e altri.

Dopo 6 mesi, poi ho deciso di tenere solo il blog, ma a parte qualche cambiamento di grafica, è rimasto così per 10 anni.

Poi, 2 anni fa, cercavo un tirocinio per l’Università e volevo che il sito potesse dare una panoramica nonché reseoconto cronografico dei miei progetti. Ne ho aprofittato per dare una rinnovata: già da diverso tempo non mi trovavo più con PHP, avevo deciso di abbandonare Flatpress e volevo che il risultato fosse più professionale. Sono passato così a Python, in particolare Django, per il backend, più un Bootstrap leggermente personalizzato per il frontend. … [Leggi il resto]

Mirror su OneDrive

Il problema

Una persona, già da diverso tempo, mi ha chiesto di aiutarla a mantenere un mirror delle cartelle importanti di un suo file server Linux sull’account OneDrive, siccome, con Office, lì ha 1TB di spazio.

Stiamo parlando di meno di 500000 file per una dimensione di circa 250GB, quindi non qualcosa di assurdamente grande, ma neanche qualcosa di proprio semplice da gestire.

Finora ho provato sia con rclone, un tool per eseguire operazioni su diversi provider cloud, in particolare di copia e sincronizzazione, sia con quello che è uno dei più diffusi client OneDrive nativi Linux, ma nessuno dei due è riuscito a gestire la cosa.

rclone deve essere uno strumento molto utile per molte situazioni, ma non per questa, perché penso che faccia costantemente richieste per verificare la struttura dei dati in OneDrive, anziché tenersi delle informazioni in locale, ma per questo motivo Microsoft lo rallenta costantemente. Invece il client OneDrive ha un database locale, ma magari a volte ci sono delle inconsistenze e si ferma, con delle eccezioni; in particolare mi sembra non gestisca bene l’essere case insensitive di OneDrive. … [Leggi il resto]