All scientific papers to be free by 2020 under EU proposals
Installing MySQL with macports
This is my notes for installing MySQL on mac. It’s mainly taken from https://trac.macports.org/wiki/howto/MySQL
sudo port install mysql56-server
which installs version 5.6, but you could check this was the latest version by search the output of
port search mysql
You need to enable the port by adding it to the system path, the easiest way is by
sudo port select mysql mysql56
Then set up the database
sudo -u _mysql mysql_install_db sudo chown -R _mysql:_mysql /opt/local/var/db/mysql56/ sudo chown -R _mysql:_mysql /opt/local/var/run/mysql56/ sudo chown -R _mysql:_mysql /opt/local/var/log/mysql56/
Then start the database
sudo port load mysql56-server
We need to set a root password
/opt/local/lib/mysql56/bin/mysqladmin -u root -p password
You will be prompted for the old password, which currently blank so just press enter, then add your new password.
You can then add some basic security to the database by running
/opt/local/bin/mysql_secure_installation
If you need the server to connect to the network (including it seems the loopback localhost – although I’m sure there is away round this), you need to edit the configuration file in /opt/local/etc/mysql56/my.conf. The file simply calls the default config file, macports-default.cnf, which stops only has skip-network in it. Don’t edit the default since an update may overwrite it, simply edit comment out the include line with a ! symbol.
To enable a C++ interface to MySQL install
sudo port install mysql5-connector-cpp
note that this also a port mysql-connector-cpp without that 5, which is broken! A half hour of my life I’ll never get back. Unfortunately this port is out of date and links against MySQL 5.1. It can still be used with 5.6 but it does mean macports will also install 5.1 on your system.
To edit the config file and your databases there is a GUI tool MySQL Workbench
From my twitter post: Ukip-backed Brexit campaign employs EU migrants to rally support https://t.co/uQdkmLuZKx
Ukip-backed Brexit campaign employs EU migrants to rally support
Exit pupil
The image of the aperture stop when viewed from the rear of the lens
Entrance pupil
The image of the aperture stop when viewed from the front of the lens
Atlas, The Next Generation – YouTube
That’s one impressive robot
Inline hologram notes
Some notes on unwrapping In line Holograms
Axis IP camera
I use axis IP camera a lot for capturing images and video. The image quality is great and they are highly customisable. I use a P1344 camera and it supports still images, MJPEG and H264. The still image are fine for capturing a one off, but too slow for video work. For this I need either MJPEG or H264. Both have there pros and cons.
MJPEG is existentially a sequence of JPEG images. It’s easy to use and the quality is good, depending on the compression settings. The downside is the bitrate over the network is larger than H264.
H264 is a lossy video compression format that has become ubiquitous on the internet these days for compressed video and blue-ray videos.
The camera can be controlled using the url. To get a H264 stream (using VLC in this case, but ffplay works perfectly well), at the command prompt type
vlc rtsp://192.168.0.103:554/axis-media/media.amp
changing the IP address to that of your camera. You can also add in the camera’s username and password using:
vlc "rtsp://192.168.0.103:554/axis-media/media.amp?user=XXX&password=XXXX"
The image resolution can be changed with
vlc rtsp://192.168.0.103:554/axis-media/media.amp?resolution=640x480
The resolution is camera dependent. There are a bunch of different settings, such as bit rate, compression, you can apply see the AXIS VAPIX documentation for the whole list. An easy way to do this is by using the cameras settings page to create a Stream Profile. There are a number built in and you can select them like so
vlc rtsp://192.168.0.103:554/axis-media/media.amp?streamprofile=Quality
Still images can be captured, by using
http://192.168.0.103/axis-cgi/jpg/image.cgi?resolution=320x240&compression=25
here I’ve selected the resolution and compression factor. You can grab the image by placing the above url into a browser.
Image Quality

Looking at the above shows subregions of example images captured at full resolution using JPG. We can see that there is significant compression artifacts in the image even at low compression ratios. Setting the compression ratio less than 40 appears to have little effect on image quality.
H264 streams appear to be similarly affected. The bitmap image shows some improvement however the data rate to transmit this is considerably larger.
Note that the RMS errors are calculated from the JPEG image with a compression factor of 0.

Benchmarking
ffplay "http://192.168.0.103/axis-cgi/mjpg/video.cgi?resolution=640x480&fps=15"
uses 60% of one core of my Odroid XU4 and 17% on my 2.7 GHz iMac
ffplay "rtsp://192.168.0.103:554/axis-media/media.amp?resolution=640x480&fps=15"
uses 88% on the Odroid and 14% on the iMac.
A useful CMake tutorial the covers VS and Xcode
Random fields & Probability cheat sheet
- Random variable – the value of a random experiment.
- Random field – a spatial function that assigns a random variable to each position
- Distribution function of a random variable (aka Cumulative distribution function, CDF)
– Consider \(P_f(z)=\mathcal{P} \{ f <z\} \) The equation tells us how likely for the random variable \(f\) to be less than \(z\). \(P_f(z)\) is the distribution function of \(f\). \(\mathcal{P} \) is the probability. - Probability of an event happening has the properties:
- It is a non-negative number
- The probability of all the events (all possible outcomes) must equal one
- The probability of a random variable taking a specific real value is zero. Loosely, this is because a real values need an infinite precision to describe them. We can however specify the probability over an infinity small range. Combining those ranges over all possible values give the probability density function.
- The probability density function is the differential of the CDF
\(p_f(z)=\frac{ d P_f(z) }{dz} \) - The expected or mean value is \(\mu_f=E\{f\}=\int_{-\infty}^{\infty} zp_f(z) dz\)
- The variance is \(\sigma^2_f=E\{(f-\mu_f)^2\}=\int_{-\infty}^{\infty} (z-\mu_f)^2p_f(z) dz\)
- If we have many random variables we can define a joint distribution function
\(P_{f_1,f_2,f_3,\ldots,f_n}(z_1,z_2,z_3 \ldots z_n)=\mathcal{P} \{ f_1 <z_1,f_2 <z_2,f_3 <z_3,\ldots,f_n <z_n \} \) - and the joint probability density function
\(p_{f_1,f_2,f_3,\ldots,f_n}(z_1,z_2,z_3 \ldots z_n)=\frac{P_{f_1,f_2,f_3,\ldots,f_n}(z_1,z_2,z_3 \ldots z_n)}{dz_1 dz_2 dz_3 \ldots dz_n} \) - If random variables are independent then
\(P_{f_1,f_2,f_3,\ldots,f_n}(z_1,z_2,z_3 \ldots z_n)=P_{f1}(z_1)P_{f2}(z_2)P_{f3}(z_3)\ldots P_{fn}(z_n)\) - If they are uncorrelated then
\(E\{f_i f_j\}=E\{f_i \}E\{f_j\} \quad , \forall i,j, i \neq j\) - and orthogonal if
\(E\{f_i f_j\}=0 \) - The covariance is \(c_{ij}=E\{(f_i-\mu_{f_i})( f_j-\mu_{f_j})\}\) which equals zero if they are uncorrelated.
Since we are interested in images (in this blog) we shall introduce random fields from this point of view. If we have a random variable at every point \(\mathbf{r}\) in a 2D space we have a random field. The random field can be written \(f(\mathbf{r},\omega_i)\) where \(\omega_i\) is the outcome. For a fixed \(\omega_i\) the random field gives a grey level image as we scan over all \(\mathbf{r}\). Scanning over all possible \(\omega_i\) gives a series of images.