sergem’s Personal public notebook

OCR in Ubuntu

A working solution to recognize a couple of pages scanned text (or photos with text) in Ubuntu 20: # install tesseract sudo apt install tesseract-ocr # find module with the language you need apt-cache search tesseract-ocr # Let's say we need german. Then we install sudo apt install tesseract-ocr-deu # Install GUI tool sudo apt install ocrfeeder The interface is relatively simple. It may require setting the default language in the settings....

April 20, 2022 · SergeM

Digital color representation

Representation of color is messed up. Here are some articles about terminology. Merging Computing with Studio Video: Converting Between R’G’B’ and 4:2:2 / pdf by Charles Poynton Upon conversion from 8-bit R’G’B’ to 8-bit Y’CBCR, three-quarters of the available colors are lost. Upon 4:2:2 subsampling, half the color detail is discarded. YUV and luminance considered harmful / pdf by Charles Poynton It was standardized for NTSC in 1953, and remains standard for all contemporary video systems, to form luma, denoted Y’, as a weighted sum of nonlinear (gamma-corrected) R’G’B’ components....

February 20, 2022 · SergeM

Image processing cheat sheet

In ImageMagick: convert save the result to a given (new) file mogrify is the same as convert but it performs processing inplace (the input files are overwritten) Strip metadata from jpg file: mogrify -strip f.jpg Rotate according the metadata, then strip: mogrify -auto-orient -strip f.jpg Find jpg and jpeg images, apply orientation from EXIF, remove metadata and resize to 1920 on the longest side preserving the aspect ratio and save to the same files:...

February 16, 2022 · SergeM

Learning Rust

Resources (books, tutorials, etc.) A half-hour to learn Rust - blog post, a great intro into the language. It may be enough to start reading the code, but not enough for writing. Easy Rust — a book about rust Many companies and people now learn Rust, and they could learn faster with a book that has easy English. This textbook is for these companies and people to learn Rust with simple English....

June 21, 2021 · SergeM

IDE for Rust

I started to learn rust, and I needed to set up some IDE to handle my exercises. It seems that VScode has pretty good support for Rust. How to set up VS code to work with rust, including debugging. Install rust-analyzer extension and vscode-lldb extension: code --install-extension matklad.rust-analyzer code --install-extension vadimcn.vscode-lldb rust-analyzer provides a nice UI for running binaries and tests: Also it gives a lot of hints: Note that rust-analyzer doesn’t work together with Rust extension (Rust for Visual Studio Code)....

May 23, 2021 · SergeM

Notes on docker

Docker ARG vs ENV https://vsupalov.com/docker-arg-vs-env/ Running GUI apps in docker ROS GUI in docker: https://tuw-cpsg.github.io/tutorials/docker-ros/ ROS GUI with NVIDIA: https://github.com/dkarunakaran/rviz_docker, https://medium.com/intro-to-artificial-intelligence/rviz-on-docker-bdf4d0fca5b rocker A tool to run docker images with customized local support injected for things like nvidia support. And user id specific files for cleaner mounting file permissions. rocker on github Build arguments example Dockerfile: FROM busybox ARG user USER $user # ... A user builds this file by calling:...

April 25, 2021 · SergeM

Graph algorithms

Shortest path problem Dijkstra’s algorithm fixes a single node as the “source” node and finds shortest paths from the source to all other nodes in the graph, producing a shortest-path tree. Wiki Dijkstra’s algorithm Complexity analysis Wiki On stack overflow: Why does Dijkstra’s algorithm use decrease-key? Actually Implementing Dijkstra’s Algorithm - complexity analysis considering three components of the main loop: time per insert, extract_min, and change_priority operation: O(nT_ins + nT_min + m*T_change)...

February 14, 2021 · SergeM

Data Structures And Algorithms in Python

Data strucures Sources: https://wiki.python.org/moin/TimeComplexity https://www.ics.uci.edu/~pattis/ICS-33/lectures/complexitypython.txt n is the number of elements in the container. k is either the value of a parameter, or the number of elements in the parameter. list It is actually an array (implemented as an array). Operation Average Case Amortized Worst Case Note Copy O(n) O(n) Append O(1) O(1) If the array grows beyond the allocated space it must be copied. In the worst case O(n) Pop last O(1) O(1) Pop intermediate O(n) O(n) Popping the intermediate element requires shifting all elements after k by one slot to the left using memmove....

January 29, 2021 · SergeM

Rounding in Python

In school we round numbers like 0.5, 1123.5 towards the bigger number. It’s a “round half up” method. That introduces an undesired bias some cases. For example if we have a large data set, and we aggregate some column containing a lot of .5 fractions. In order to adjust for it in many cases a rounding of 0.5 towards nearest even number is applied. It’s “Rounding half to even” or “banker’s rounding”....

January 10, 2021 · SergeM

Symbolic math and python

With the help of python and SymPy module one can do pretty neat computations. For example when I took a course about Robotic Preception on Coursera I had to find a cross product of two vectors v1 x v2 represented in a generic form: v1 = (a, b, c) v2 = (d, e, 0) Normally I would write it down on a piece of paper and do the computations myself. Luckily python can help with that....

December 31, 2020 · SergeM