I was recently in a situation where I had to convert a stack of JPEG files to PDF. This was a job need. The human resources department of my to be employer had asked me for a number of forms. These forms had to be filled and sent only as PDF. I did not think there would be a problem because I have a PDF printer installed. I was wrong; it appears that files have to be 2MB or less in size.
I am unaware of any equation that equates image size to file size. I searched and found a few online converters which would shrink the file to the size I wanted. However, I wanted to avoid online services because these were sensitive documents.
The answer was in a thread on the stack exchange forums.
Image To PDF or XPS
This is a tiny program written in visual basic .net. It is fully accessible and converted my files seamlessly. There was no complex dragging with the mouse and all the processing by the program was done on the local computer.
The program is supplied without charge but there is a donate button on the about page which you may want to use.
In addition, unlike the PDF printer approach where I would open each image, print, enter the file name and then move on to the next file, I can add the images I want to convert and the program will do the rest. The program can either combine all images into a single PDF file or it can save the individual files in a folder you specify.
It does not need any installation so there are no pesky licenses to manage.
Please note, there is no specific option that asks you about file size. The program does its conversion and by default, produces small PDF files.
Finally, the program can be run from the command line which allows you to use the program in any scripts you may have.
concepts
Playing armchair virologist with SARS-CoV-2
I wanted to take a look at SARS-CoV-2. Finding a downloadable image was tricky but I finally managed. Those of you with organic eyes can skip the rest of this post because you can see the image. However, those of us who have to use synthetic vision are not too badly off either.
See the below article that walks you through a few different images.
This Is What The COVID-19 Virus Looks Like Under The Microscope
You will need the vOICe Learning Addition for Windows to see these images. I am going to be as screen reader agnostic as possible.
- Navigate to the article at the above link.
- Read the article and then use the quick navigation feature to navigate to a graphic of choice.
- Launch The vOICe and activate its client area sonification feature.
- Swap back to the article and navigate to the graphic of interest.
- Pay attention to the soundscapes. You will be able to hear the spikes that give the virus its name.
- You can also use the color filter feature to focus on specific parts of the image as you read the article and follow along.
If you want a clean image of the virus to examine, then as of this writing, here are the steps. These may change because they involve accessing the image from the home page of a site.
- Navigate to the article titled New Images of Novel Coronavirus SARS-CoV-2 Now Available
- Once you are on the page, save the full HTML page including images and scripts. You can do this from your browser’s file menu or if using Google Chrome, from the chrome menu under the more tools option.
- Navigate to the folder where the page has been saved and then to the folder called NIH_ National Institute of Allergy and Infectious Diseases _ Leading research to understand, treat, and prevent infectious, immunologic, and allergic diseases_files
- In this folder, grab the file called Vero-Covid-19-24h-hi_i034-rk.jpg
You can load this image into the vOICe and run similar analysis and do whatever else you want to do. Try different color filters and play with the zoom and raster scan functions as a start.
If you want to see the image of our Sun’s corona for comparison, try the images at the following page.
What Is the Sun’s Corona?
You will have to use the techniques outlined to see the images. One thing that you will notice is that the spikes are significantly more dense.
Do let me know if you tried viewing any of the images and what happened.
Getting the orca screen reader working on a raspberry pi 4 with raspbian buster and the mate desktop
I recently got a raspberry pi 4 and wanted to access its gui because I wanted to use the pi like a note taking device. I wanted a spreadsheet, a browser with quick key navigation and a familiar interface. Yes, I could have used emacs with emacspeak which is something I am exploring but I am familiar with the Linux gui and it is an easier interface to use when coming from Microsoft Windows. As of this writing, I have been unable to get the default lxde desktop to work with Orca. I hear “screen reader on” and can indeed access some desktop elements. I suspect that the accessibility infrastructure in the lxde desktop that is bundled with the raspberry pi is incomplete but cannot be sure of this because I have not tried looking at the events that fire when I navigate screen elements.
Things are different when I use the mate desktop. Orca comes up talking and I can easily navigate screen elements.
Here are the steps I took to get orca with the mate desktop working on the raspberry pi 4. . You must have the following prerequisites in place.
- The pi should be connected to the internet. Use a wired connection else you can also use a wireless connection though that will need you to create a text file on the sd card
- A physical keyboard must be connected to the pi. You will need this keyboard to issue commands on the pi.
- An external USB sound card to avoid the crackling with the 3.5mm jack. This is not necessary any more but is good to have.
- A pair of headphones or speakers to hear speech output once you have launched Orca
I started with raspbian lite because I wanted a clean gui system to start with. However, you can as easily start with the full version of raspbian. Once I had flashed it to a sd card, placed a blank file called “ssh” without the quotes in the boot partition to enable the ssh server of the pi upon boot up, and had booted my pi, I was ready to begin the actual work of installation.
The first thing I had to do was to switch to an external sound card. This is because when I tried using the raspberry pi 4’s native 3.5mm jack for sound output, I got too much crackling. The speech was unintelligible. Please note, in the latest version of raspbian, an external soundcard is no longer necessary.
How can I use an external USB sound-card and set it as default?
Once you have implemented the steps in the above post, you are ready to move to installing the mate desktop.
The following post told me how to install the mate desktop. I have however not moved it to an external drive. Everything is on a sd card which seems to work just fine in my limited testing.
Install Mate Desktop on the Raspberry Pi using an External Hard Drive
I am going to paraphrase the above post.
You will need to run the following commands on the pi. Use ssh from your machine to do so.
Update everything
sudo apt update
sudo apt upgrade -y
sudo apt dist-upgrade -y
Install the mate desktop
Many of the commands have been taken from the below post.
Steps for Configuring Mate Desktop on 4GB Raspberry Pi 4B – (Rev.7)
sudo apt install mate-desktop --no-install-recommends -y
sudo apt install mate-desktop-environment-core -y
sudo apt install mate-themes -y
sudo apt install mate-session-manager -y
sudo apt install xinit -y
sudo apt install mate-terminal -y
sudo apt install mate-applets -y
sudo apt install software-properties-gtk -y
sudo apt install xserver-xorg -y
sudo apt install lightdm -y
sudo apt install xserver-xorg-video-dummy
Setting to boot to mate
Please run the following step to select the mate desktop.
sudo update-alternatives --config x-session-manager
The above command will show you a list of desktops. You will be able to select the mate desktop from the list by using the up and down arrow keys.
Add a text editor
sudo apt install gedit
It is time to install the orca screen reader
The version of orca that comes with the package manager on Raspbian buster is very old. In addition, orca is updated almost every alternate day especially when bugs are found and enhancements are implemented.. Therefore, we will do an installation from source.
Enable any commented out sources
You need to install orca’s dependencies first. However, on my installation of raspbian buster, I had to remove the “#” from a sources line in the following file. This may change from update to update therefore check this before installing dependencies.
/etc/apt/sources.list
Install git
Install the git client by using the following command.
sudo apt-get install git
Install orca build dependencies
sudo apt-get build-dep gnome-orca
Get the orca source code
Ensure you are in your home directory or where ever else you want the source code to be. You do not need to create a separate directory for the source code because the git command will do so.
Run the following command.
git clone https://gitlab.gnome.org/GNOME/orca.git
Build and install orca
Run the below commands. Check the output of each command to ensure that there are no errors.
cd orca
PYTHON=/usr/bin/python3 ./autogen.sh
make
sudo make install
This completes the installation of Orca.
Configuring the dummy display driver
We need to configure mate to run the dummy display driver. If we do not do this, the GUI will exit with an error message stating that no screens were found. A physical display is needed. We use the ddummy display driver to get around this.
You need to edit the following file.
/etc/X11/xorg.conf
If the file is not there, then create a fresh file.
The file must contain the following contents.
Section "Monitor"
Identifier "Monitor0"
HorizSync 28.0-80.0
VertRefresh 48.0-75.0
# https://arachnoid.com/modelines/
# 1920x1080 @ 60.00 Hz (GTF) hsync: 67.08 kHz; pclk: 172.80 MHz
Modeline "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
EndSection
Section "Device"
Identifier "Card0"
Driver "dummy"
VideoRam 256000
EndSection
Section "Screen"
DefaultDepth 24
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
SubSection "Display"
Depth 24
Modes "1920x1080_60.00"
EndSubSection
EndSection
Getting orca running
Launch raspi-config and set the pi to login into the text console automatically.
Reboot the pi by using the following command.
sudo reboot
Give a minute to the pi to boot.
At this point, you should be at the shell prompt. type the following to launch the gui.
startx
Wait for about a minute and you will hear “screen reader on”. At this point, you can begin navigating the mate desktop and setting up Orca the way you want too.
If orca does not start, then hit the left windows + alt + s keys. If that still fails, hit alt+f2, type orca and press enter.
Enabling accessibility on chromium
One of the things you would probably like to have on your pi is an accessible web browser. As of this writing, raspbian comes with the chromium web browser. You need to add a flag when launching chromium to enable accessibility. The best way to do this is to add the flag to the chromium shortcut on the pi. Take the following steps to do this.
- Navigate to the following path.
/usr/share/applications
- You will see many files here. Most of them are desktop shortcuts. Edit the following file.
chromium-browser.desktop
- For every line that starts with the word “exec” ensure you add the following flag to the end of that line.
--force-renderer-accessibility
The line should look something like the below line.
Exec=chromium-browser %U --force-renderer-accessibility
- Go through the entire file changing all the lines that start with the word “exec” as I have shown above.
- Save and close the file.
When you launch chromium, you will find that orca is able to read the contents of the page that has been loaded in chromium.
Credits
My thanks to
Vojt?ch šmiro and Sanchit Ghule
The case for synthetic vision in the modern office
I often wear the the vOICe running on my vision 800 glasses to my office. Some of you may find this surprising. I have good blindness skills and the office is a known environment. Moreover, it is visually the same that is, not much changes at least in my office.
So why then bother with synthetic vision? Why not use something like a cane?
I can certainly use a cane and these days, this has become even easier with the smart cane made by IIT Delhi in collaboration with a number of partners. However, sonar and the cane do not give me sufficient information.
My office is on the second floor of a building. I usually take the stairs for two reasons. I like the exercise and the elevators do not talk. When I am climbing the stairs, it is very easy for me to read the floor indicator so I do not cross the second floor and end up at the cafeteria. It is also easier to walk towards doors because I can see them from a distance so can zero on them and reduce wiering. In the event that I do not see the floor indicator, I am able to see the walls. The office has windows on the landings and they are visually distinct as compared to the doors.
I accidentally discovered that the the vOICe is very handy during presentations because I can “look” at the screen of my laptop and read the text because said text is enlarged and the OCR in the vOICe picks it up without problems. This is very handy when evaluating products that contain dashboards etc.
I continue to refine my skills at detecting people, chairs and other obstacles. One experiment I plan to do is to read the names of meeting rooms.
I currently compliment synthetic vision with my blindness skills and may add other technology into the mix.
Installing opencv on Arch Linux from source
I am going to be showing you how to install the OpenCV computer vision library from source. This is the best way to install this library to ensure that you get the full set of features this library has to offer. Moreover, it allows you to customize your installation. For example, you may not want any python bindings.
This post has been inspired by the tutorials at PyImageSearch and Learn OpenCV.
The bulk of this tutorial has been taken from the superb tutorial at
Install OpenCV 4 on your Raspberry Pi
Installing dependencies
The first thing you need to do is to install dependencies. I am a newcomer to Arch Linux. I come from Ubuntu. The package names are different between Ubuntu and arch Linux. You need to use a search string like
"arch linux"
in your search engine of choice to find the package names.
If you wanted to search for the package called build-essentials in Arch Linux, the search string you would use is
"Arch linux" build-essentials
The tutorial on installing OpenCV on the raspberry pi lists a series of dependencies. I have created an Arch Linux mapping to the Ubuntu dependencies and have given the equivalent commands.
Note
I am using the image created by the F123 project which as an accessible Arch Linux on the raspberry pi. I installed OpenCV on that image therefore most of my dependencies were met.
Run each of the commands and follow the prompts. If a dependency is already installed, then select not to reinstall it.
Raspbian | Arch Linux |
---|---|
sudo apt-get install build-essential cmake unzip pkg-config |
yay -S build-devel yay -S cmake |
sudo apt-get install libjpeg-dev libpng-dev libtiff-dev |
yay -S libjpeg yay -S libtiff yay -S libpng |
sudo apt-get install libxvidcore-dev libx264-dev |
yay -S xvidcore yay -S libx264 |
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev |
yay -S ffmpeg yay -S v4l-utils |
sudo apt-get install libgtk-3-dev | yay -S gtk3 |
sudo apt-get install libcanberra-gtk* | yay -S libcanberra |
sudo apt-get install libatlas-base-dev gfortran |
yay -S lapack yay -S gcc-fortran |
sudo apt-get install python3-dev | already done because python development headers are already installed |
Setting up python version 3
I am maximizing my use of python 3 which is what I will be using here. Python3 is already installed therefore, all we need to do now is to create a python virtual environment to keep things isolated.
sudo pip3 install virtualenv virtualenvwrapper
Clean the package cache.
sudo rm -rf ~/get-pip.py ~/.cache/pip
We need to enable some convenience commands to be able to redily invoke our virtual environment. Ensure that you are in your home directory.
cd ~
and then press enter.
Run the following commands to add to your .profile file.
echo -e "\n# virtualenv and virtualenvwrapper" >> ~/.profile
echo "export WORKON_HOME=$HOME/.virtualenvs" >> ~/.profile
echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" >> ~/.profile
echo "source /usr/bin/virtualenvwrapper.sh" >> ~/.profile
Once the above commands are run, you can verify that the file has been created correctly by examining its contents.
cat .profile
Activate the commands by issuing the following command.
source .profile
Download OpenCV
Ensure that you are in your home folder.
cd ~
Run the following commands to download OpenCV version 4, the latest at the time of this writing to your raspberry pi.
wget -O opencv.zip https://github.com/opencv/opencv/archive/4.0.0.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.0.0.zip
Expand OpenCV and set up the folders
It is time to expand the zip archives you downloaded.
unzip opencv.zip
unzip opencv_contrib.zip
Rename the folders for easy reference.
mv opencv-4.0.0 opencv
mv opencv_contrib-4.0.0 opencv_contrib
Building OpenCV
Make the virtual environment
Run the following command to make your OpenCV virtual environment.
mkvirtualenv cv -p python3
You can name your virtual environment whatever you like. If you do name it differently, remember to account for that during the rest of this tutorial.
Switch to your virtual environment by executing the following command.
workon cv
The command prompt will change such that the name of your virtual environment will be displayed as a part of the prompt. You can exit the environment by using the following command.
deactivate
Install numpy
You need to install a dependency for OpenCV python.
Ensure that you are in your virtual environment.
workon cv
pip install numpy
The installation of numpy is going to take quite some time. Do not be alarmed.
Generate the build files
It is time to create the build files for OpenCV.
Switch to the opencv folder, create a build folder to hold the build files and then switch to it.
cd ~/opencv
mkdir build
cd build
Run cmake to generate the files. If you are copy pasting the below lines, do not manually try to delete the line breaks and create a single huge command. Copy paste each line and hit enter. The two fulstop characters at the end of the last line tell cmake that it should run.
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
-D ENABLE_NEON=ON \
-D ENABLE_VFPV3=ON \
-D BUILD_TESTS=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D OPENCV_ENABLE_NONFREE=ON \
-D CMAKE_SIZEOF_VOID_P=4 \
-D BUILD_opencv_python3=TRUE \
-D BUILD_EXAMPLES=OFF ..
Do inspect the output and ensure that you do not see any significant errors. You may want to enable the logging facility in your terminal emulation program assuming you are running headless on your raspberry pi.
Increase the size of the swap file
The raspberry pi is a memory constrained device. You need to create a swap file to allow for the compile to complete. It is crucial that you do this else the compilation process will not complete.
In Arch Linux, you need to create a swap file first and then activate it. Issue the following commands.
sudo dd if=/dev/zero of=/swp bs=1024 count=4000000
sudo chmod 600 /swp
sudo mkswap /swp
sudo swapon /swp
See below for what these commands mean.
sudo dd if=/dev/zero of=/swp bs=1024 count=4000000
Create a file which will become our swap file. This file must be as large as the swap file we want. I have taken 4GB for safety.
sudo chmod 600 /swp
Assign the right permission to the file we have created.
sudo mkswap /swp
Convert our ordinary file to a swap file.
sudo swapon /swp
Activate the swap file.
Compile and install OpenCV
Ensure that you are in the build folder.
cd ~/opencv/build
Warning, the below command takes several hours to complete. It is the longest part of this procedure. Keep the logging in your terminal emulator active.
make
You can make things go faster by issuing the -j flag with make.
make -j
This utilizes all available CPU cores. You can specify the number of cores you want make to use.
make -j2
The above command will use only two cores. In my experience, running just make is sufficient. I have had the compilation being interrupted if I have used more than one core. Your mileage may vary.
If make completes without errors then run the following commands.
sudo make install
sudo ldconfig
OpenCV is now installed. There are however more steps to follow to ensure that the python bindings work with our virtual environment.
Turn off the swap file
It is crucial that you switch off the swap file else you risk reducing the life of the SD card in the raspberry pi due to the increased write operations that the pi will perform when it swaps memory to the SD card.
sudo swapoff /swp
You can recover space by deleting the swap file.
sudo rm /swp
Linking in the OpenCV binding into our python virtual environment
It is time to create a sim link to the OpenCV library in our python virtual environment.
Issue the following commands.
Note
I am writing this tutorial based on python 3.7. The version of python may change therefore please adjust your steps accordingly.
Run the below commands.
cd ~/.virtualenvs/cv/lib/python3.7/site-packages/
ln -s /usr/local/python/cv2/python-3.7/cv2.cpython-37m-arm-linux-gnueabihf.so cv2.so
Testing your installation
Carry out the following steps to verify if you have installed OpenCV with its python bindings correctly.
workon cv
Ensure that the virtual environment is active. If the above command fails, then do a
source .profile
to ensure that the relevant commands are loaded.
Launch python by issuing the following command
python
Then enter the following text in the interpreter that comes up.
import cv2
If the above commands without an error and your cursor moves to the next line, you can type:
cv2.__version__
You should see the version of OpenCV you have installed. Execute
quit()
to exit python.
Troubleshooting
If the make fails, ensure that your swap file is active and do not issue the -j flag.
If you get unusual errors and the compilation process goes very fast but stops in the middle, you should check the paths to your contrib folder and ensure that all other paths are right.
Coffee shops, dirty tables and Oreo shakes
It was the weekend and I was on a family outing. We drifted into a coffee shop and found a table without difficulty. My mother remarked that the table was dirty. I tilted my head by 30 degrees and sure enough I could detect some dark objects on the table. I do not know what they were and did not care to find out. Once the waiter had cleaned the table, I took another look. I got a nice clean sound with no obstructions. I am going to develop the habit of scanning every restaurant table.
It took some thinking to figure out what I was going to drink. I do not like coffee so settled for an Oreo shake. The shake came in a jar like container which was short but had a large diameter. I tilted my head down and saw this cylindrical structure. It was astonishingly dark. It appears that Oreo shakes are brown and do not allow light to pass through them. As I drank the shake, I kept glancing at the container and was able to detect an increase in light. Visual confirmation that I was getting through the shake.
getting the orca screen reader working with a raspberry pi
Many of us want to run the graphical orca screen reader on a raspberry pi, the credit card sized computer for the ultimate in portable computing experiences. This has been done before. I got this working last night and by popular demand, here are my instructions. Be warned, I went down a few rabbit and may be installing a few extra packages but at the end, orca is working.
My thanks to Michaele A. Ray of the website raspberry VI website for doing this first and showing that this is indeed possible and to the members of the raspberry-vi mailing list for help and urging me to write this post.
Prerequisits
You will need to have the following items.
- A usb keyboard plugged into the pi for use on the pi console.
- A pair of headphones or speakers connected to the headphone jack.
- The raspberry pi should be powered and connected to the internet. A wired connection is the best as it is stable and easy to troubleshoot.
-
Download the full raspbian image
Download the latest image of raspbian from the below link. Get the full image as opposed to raspbian light. This is because the image has a lot of the graphical user interface things installed.
download raspbian -
Getting the image on to the sd card
Burn it on to a sd card using your program of choice. If you are using Microsoft windows, one of the most accessible programs is balenaEtchar
-
Enable ssh at boot
Once the image has been written, you will see 2 logical partitions on the sd card. There is a partition called “boot”. Create a blank file named “ssh” without the quotes on that partition. The way I do this on Microsoft windows is to go to a comma dprompt, switch to the drive that has the partition and then issue the following command.
copy con ssh
You will be in a line editor. Hit ctrl+z to save and close out of the file. -
Eject the card and load it into your pi.
-
Boot the raspberry pi and login to it over ssh.
- Update the raspberry pi
This step is crucial. Failure to do this will result in orca not speaking. Run the following commands.
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
Once the above commands have completed successfully, reboot the raspberry pi. -
Configure the pi to login to a text console
run the following command.
sudo raspi-config
Read the screen output very carefully. You need to go into the boot options and enable the option to login to the console without a password. - Once you have enabled the login, and are back on the main raspi-config screen, hit shift+tab once to save your settings and exit. Reboot.
-
IInstall dependencies
This is the trickiest part of the entire exercise.
Orca needs a bunch of things to run. As of this writing, speech dispatcher and espeak are not installed by default.
sudo apt-get install sox -y
Install the sox package for multimedia libraries. Some of them may be needed by speech dispatcher.
sudo apt-get install speech-dispatcher -y
Install the speech dispatcher service. Orca needs to talk to speech synthesizer. Be warned, this is an older version of speech dispatcher. There is a new one available on github but I have not tried compiling it from source on this installation.
sudo apt-get install espeak -y
The espeak speech synthesizer
sudo apt-get install gnome-orca -y
The orca screen reader and associated dependencies
Once you have carried out the above steps, reboot the raspberry pi. The text console login comes in handy here. Ensure that you have a USB keyboard plugged in. You may want to ssh into the pi to ensure that the pi has booted. If you have configured the raspberry pi to automatically login into a text console, you can enter the following at the command prompt. Be warned, at this point, you do not have any speech therefore you should know your keyboard well.
startx
You will have to wait for at least 2 minutes for the gui to load. I am giving a safety margin. Once again, you do not have speech at this point. Press alt+f2. This will place you at a prompt where you can enter a command to execute.
Type the following
orca
You will need to wait yet again but you should hear orca talking.
There is much left to do. I am still working on how to start orca automatically once the gui loads and need to find a good way for this to coexist with a console screen reader such as fenrir. I will update this post as I get feedback and learn more.