## OpenCV feature detection and tracking

Wrote some utter shit code to get started with tracking via feature detection. Probably not the best way to go about the business.

Click on the screen to pick the green dot to follow

Uses the ORB feature finder. Each feature then has a descriptor and does brute force search to find best one.

Needs a lot more to be useful for anything. Suggestions: reject outliers, take best k matches and pick closest one to previous match, maintain a set of best current descriptors.

This is another approach to following something, but I’m not sure it is a great one.

## Knife Bot

Knife bot. Hide your children and wives and dogs.

It’s a hot glued arrangement of servos and home depot painter sticks (they’re free!)

We used python and numpy to solve for the needed angles as a function of the end position. We were having trouble with getting angles that are in the -np.pi/2 to np.pi/2 range until the suggestion of using [0,np.pi/2] as the initial position. In hindsight, a more robust method would be to make a loop attempting a set of reasonable starting positions, and accept them if they were attainable. Or to attempt a random set of initial conditions. Your choice. For only 2 variables, the computer will just chew that problem up. If you had 10 actuators, maybe you’d have more problems.

Turns out random angles mode was more fun though.

This is the arduino code. Servos are on 9,10,11

We dialed in the Zero and Ration numbers by iteratively try to get angle 0 and 90 degrees manually over the serial monitor for each servo in turn.

The command strings is in the format

Comma separated angles for each motor in radians.

## More Opencv

Canny finds edges. Edges are basically places of very large derivative in the image. Then the canny algorithm cleans it up a little.

FindContours seems to be a clutch dude

http://dsynflo.blogspot.com/2014/10/opencv-qr-code-detection-and-extraction.html

This guy uses it to

The dilation reduces the number of contours to something more reasonable

Each contour is of the format [[[x y]], [[x y]], [[x y]]]

I had a problem with draw contours until I found out I needed to write onto a color image with it.

The good features to track

The 25 is number of corners, 0.01 is a quality cutoff (1% of best corner quality found), 10 is minimum distance between corners

## Ubuntu Virtualbox

Make a new virtual machine. Linux 64-bit probably

Under storage go the the cd and click on it. Select the installation disk.

Decide to erase and install, it’s fine.

Insert the guest additions cd using the menu bar under devices. Install them. Now it should go full screen when you click the little green button on macs. You can slide all your fingers to switch workspaces.

TO be able to access shared folders

Also, checking 3d acceleration under Settings > Display and giving it all the video ram you can seems to make it run much zippier.

I also gave it 3gb of ram because i had a little extra to spare. Seems to like it.

Can use a more lightweight desktop environment by selecting that little emblem at the login screen.

## ipywidgets: useful little buggers

So, the matplotlib slider functionality is basically garbage.

Let’s see if ipywidgets and ipython notebooks do better

A basic program with sliders. You can go from there.

## Performing Some Laplace Experiments

So I’m looking at the sparse solver capabilities of python.

Trying a 3d poisson problem (electrostatics of a point charge) in V=0 boundary conditions

$\nabla^2 \phi = \delta^3 (x)$

Looks like a sphere. Cool.

Using scikit-image for finding the isosurface (constant potential surface). Ripped right from their examples.

http://scikit-image.org/docs/dev/auto_examples/plot_marching_cubes.html

Note that it needs to be rescaled, since verts is in the integer index format.

Seems to work. Takes a couple seconds to finish on my macbook pro at N=25.

## NMR: a baby birds first fall from the nest

The idea is to attempt to use commodity hardware (standard hacker toolkit) to see an NMR signal

We bought 3 disk magnets from amazon. 1.5″x.25″.

Using our magnetometer made from a hall effect sensor, we’re getting that that field in the bore ~0.5T.

Going off a guess that disk magnets have fields approximately that of coils, a helmholtz coil arrangement was attempted with 3d printed parts. The fit of the magnets in there is really tight.

We saturated the sensor (which saturates at 0.3T), but with theoretically the thing is taking the dot product with it’s orientation with respect to the field. A perpendicular sensor does read approximately 0T. So we attenuated the field by tilting the sensor 45/2 degrees off of perpendicular and measured ~0.17T.

For the hydrogen nucleus, this is a resoannce freqeuncy of ~20Mhz.

We designed a helmholtz coil setup (coils that are 1 radius apart. They look unnaturally close to my eye for some reason, but that it just opinion.), Oversizing things that have to fit by 0.01inch seems enough for a snug fit. Your mileage may vary.

It is quite unclear to me the electrical characteristics these coils are going to have at the design frequency of ~20Mhz.

Here is a GUESS. I haven’t really done much hard work on this. But it’s probably right to order of magnitude. The B is fairly uniform in the helmholtz coil. Basically the same result for a solenoid of same size.

N is number of turns on one coil.

$B = (4/5)^{3/2} \mu_0 N I / r$

$\Phi = L I$

$\Phi = 2 N A B$

$L =(4/5)^{3/2} \mu_0 N^2 2 \pi r$

$A = \pi r^2$

Gives an inductance of 7uH, impedance of ~1kOhm at 20Mhz with 10 turns per coil.

This estimate was confirmed

http://www.benwiener.com/index.php/2015/12/16/some-rf-learnin/

## Interesting Command Line Guys: Sox and Socat

http://kmkeen.com/rtl-demod-guide/

Check out Socat. Let’s you pipe a file quickly over tcp and then grab it with netcat. Makes sense.

https://github.com/simonyiszk/minidemod

Sox is a sound processing swiss army knife. Intriguing. Use it like image magick. Can quickly resample sound. That’s what the rate 48000 does. -r specifies that rtl-sdr is outputting 240000 samples per second. -b is that they are byte samples. -c 1 is one channel (as compared to stereo)

spectrogram is an interesting option. It can produce a spectrogram of the signal. Could use this as a waterfall plot.

synth is also interesting. Can be used to make waveforms.

3 second sweep of a sine wave. 300Hz-3300Hz

http://sox.sourceforge.net/sox.html

http://sox.sourceforge.net/sox.html

http://sox.sourceforge.net/sox.html

## A fun little man of rutherford scattering

So I coded up rutherford scattering in a real dumb way (you can significantly reduce your considerations by using symmetry and stuff).

I sort of monte carlo it with gaussian distributed initial conditions

The bundles that come off look pretty cool

Lots that one could do with this. Compare the outgoing distribution to the formula, Try to discern shape of other potentials. Do a little statistics to see if charge or whatever can be determined from the data.

Show center of mass scattering. Try 4 particle scattering.

I guess I’m trying to play around in some high energy concepts.

You can take a big honkin spectrum with rtl_power

http://kmkeen.com/rtl-power/

Frequency range and steps are self explanatory. Maximum steps is 2M ish (max sampling rate of SDR)

-i is integration time for each step (defualt is 10s)

-e is timeout time (will go forever if you don’t set)

-g is gain

Each line of the output is one window of sampling basically. The db values at the end are interpolating the frequencies in the window of the line.

Set -i and -e to the same number to just take one spectrum.

flatten.py  converts to a more sane format for my purposes, a list of frequencies and powers.

Then a short python script

that talks the csv filename as an argument will make a simple plot. You could also do this with plt.plotfile maybe? Something to investigate in the future. numpy.loadtxt is pretty clutch.

Or you can just spreadsheet it up

or use gnuplot (ick)

http://heat.wq.lc/#

Also,  you can get a simple scope in gnuradio by just taking the rtl_sdr block and hook it right up to a scope block. Pretty Handy little guy.

Autocompleting gr_ ( double tab ) on my comp gives a list of interesting built ins:

gr_constellation_plot  gr_plot_psd_c          gr_spectrogram_plot_c

gr_filter_design       gr_plot_psd_f          gr_spectrogram_plot_f

gr_modtool             gr_plot_qt             gr_spectrogram_plot_i

gr_plot_char           gr_plot_short          gr_spectrogram_plot_s

gr_plot_const          gr_psd_plot_b          gr_time_plot_b

gr_plot_fft            gr_psd_plot_c          gr_time_plot_c

gr_plot_fft_c          gr_psd_plot_f          gr_time_plot_f

gr_plot_fft_f          gr_psd_plot_i          gr_time_plot_i

gr_plot_float          gr_psd_plot_s          gr_time_plot_s