Pages

Tuesday, January 5, 2016

video stream Motion detector

motion

http://www.lavrsen.dk/foswiki/bin/view/Motion/MotionGuide

intro

capture video streams to file. detects changes to the video stream using various strategies to start capture. optionally saves event to database.

install

sudo apt-get install motion

configure

/etc/motion/motion.conf
/etc/default/motion

add group/user motion to the image dump folder

sudo chown -R motion:motion /media/storage/motion

motion installs with user and group called motion

  • add your user account to motion group
sudo usermod -a -G motion kirk

get a better understanding of the available camera

v4l2-ctl --list-formats-ext

starting the service

sudo service motion start

database

encountered a bug with mysql deprecated timestamp
https://bugs.mysql.com/bug.php?id=41510
CREATE TABLE security (camera int, filename char(80) not null, frame int, filetype int, timestamp timestamp(14), text_event timestamp(14));
resolve:
CREATE TABLE security (camera int, filename char(80) not null, frame int, filetype int, timestamp timestamp, text_event timestamp);
then added a mysql user a root:
CREATE USER 'motion'@'localhost' IDENTIFIED BY 'l1tsp33D';
GRANT SELECT, INSERT ON motion.security TO 'motion'@'localhost';
encountered another issue with the motion.conf file having eventtimestamp as a column name but the documentation has text_event.
sqlquery insert into security(camera, filename, frame, filetype, timestamp, eventtime_stamp) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C')
Altered the conf file to match the table I created.

error

vim /var/log/syslog

Tuesday, September 29, 2015

Testing with Android Studio

Tried to write this in the order one would discover how to configure and test in Android Studio. Test support has come in many forms with different purposes in AS(Android Studio). There are/were plugins and various 3rd pty libs. AS now supplies its own test platform. None of which is configured to fly right out of the box.

Setup

Get the Android Support Library from SDK manager. Recently the manager has been moved to the setting interface. You can still get to the old sdk interface.
Testing Support
Verify you have the libs in your sdk folder.
<sdk>/extras/android/m2repository/com/android/support/test

Create a new project to test with.

Create a new blank activity app.
  • compile app
  • open the default MainActivity class
Gradle plugin testInstrumentationRunner needs overriding.
  • Manually change the build.gradle file. If you search the gradle site for testInstrumentationRunner you will see the default is “android.test.InstrumentationTestRunner”.
  • Wasn’t able to find UI way to change this value.
  • This will come in handy as it supplies a value for the debug/run config interface.
defaultConfig {
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
Open create test interface
  • right click on the MainActivity class name -> Go To -> Test
  • CTRL + SHIFT + T
Configure the test interface
  • select JUnit4 and Fix (what does fix do?)
  • select one or more methods to test and before after checks
  • should create import statments and test methods in test class
choose the destination test directory interface
  • the one that contains “src” in the path
  • this can be a larger list if you have other modules in your project
Should have a new file MainActivityTest in the test directory.
  • The build.gradel file still does not have reference to the important libs we are going to use “com.android.support.*”
Apply the first annotation that requires reference
  • Add @RunWith(AndroidJUnit4.class) to test class
  • Alt + Enter @RunWith to create import
  • AndroidJUnit4 class reference not found. Dependencies missing.
Add android.support.test.* dependencies to the project
  • modifying build.gradle is can be done via the project structure interface. (or manually)
  • select your app right click and select "open module setting (F4)
  • select the module app and choose the dependicies tab
  • find the + - buttons + add the “library dependency”
  • paste in the full lib name in the “choose library dependency” interface. It will not work with a partial match.
  • change the “scope” to Test compile.
  • OK, clean, compile
  • you should see the new references in the (app)build.gradle file.
Here are the latest libs for test support. They will change.
'com.android.support.test:runner:0.4'
'com.android.support.test:rules:0.4'
'com.android.support.test.espresso:espresso-core:2.2.1'
'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
'com.android.support:support-annotations:23.0.1'
Others
org.hamcrest:hamcrest-library:1.3
Add the import reference AndroidJUnit4.class
  • dependency should now exist for AndroidJUnit4.class
  • Alt + Enter AndroidJUnit4 to create import
Setup one test to Pass
  • we will use assertThat from hamcrest.org
  • add this test method
@Test
public void DonkeyTest() throws Exception {
    assertThat("", is(""));
}
  • Alt + Enter “assertThat” to create import
  • Alt + Enter “is” to create import
Try running the test
  • Right click on test class file. Should see Create, debug, run
  • Select Create to generate a run configuration
  • The “Specific Instrumentation runner(optional):” is not optional. Should be already set to “android.support.test.runner.AndroidJUnitRunner”
  • if not select … and choose “android.support.test.runner.AndroidJUnitRunner”
  • Apply, Ok
  • Right click again and select run/debug
  • If you goto “Edit Configurations” you can delete what was made in this step.
Locate the results
  • Run dialog should show the Result / Command / Test Method

Conclusions

Getting an idea of where all the moving parts are is a good first step. Primary suspects is the presense of the testing libraries and the correct configuration of the build.gradle.
There are a lot of new api introduced which can be overwhelming. Hard to tell which is the current official storyline.
Google is making attempts at gathering this config stuff in one spot with Android Testing Blueprint

Links

Friday, September 11, 2015

Virtualenv

Arriving at the conclusion that you need virtualenv you quickly enter into how_where_what land.  Your why is because you want multiple versions of python and to pip packages to your hearts content.

This site virtualenv sums it up pretty well but is kind of light on the details.  After reading it you start wandering around for more answers.   Each environment kind of has its own tricks and traps.

I wanted to know how-does-virtualenv-work without reverse-engineering-ian-bicking.  Final answer is: this shell these paths please. 

Before getting into virtualenv you would want to know more about "pip" (package manager).   Pip is one of a set of tools that put the python packages into the python user space.  

So don't forget that the virtualenv command just populates a directory with all the folders and symlinks to the python binaries you want.  

activate and deactivate command exist in reference to the environment that was setup by virtualenv.  They engage and disengage those paths that now exist as directories in your directory.

Install

sudo apt-get install python-dev python-pip python-virtualenv

Setup

Really good rundown on setting up. run-multiple-python-versions-on-your.  Pay attention to the how he manages his environments and the use of ~/.bash_alias

Links



how-does-virtualenv-work

Friday, May 1, 2015

Ubuntu 14 Android Studio setup notes


Setting up Android Studio on Ubuntu requires many extra packages. Here are some notes on setting up the latest versions. Special note that you want a CPU that supports the android emulator. I used an AMD with graphics support.

-------------------
#requires java 7

sudo apt-get install default-jdk

#getting the packages

mkdir Android

cd Android

wget http://dl.google.com/android/android-sdk_r24.0.2-linux.tgz

tar -xvzf android-sdk_r24.0.2-linux.tgz

wget https://dl.google.com/dl/android/studio/ide-zips/1.1.0/android-studio-ide-135.1740770-linux.zip

unzip android-studio-ide-135.1740770-linux.zip

#add $PATH to end of  ~/.bashrc file

export PATH=$PATH:~/Android/android-studio/bin

#required packages 

sudo dpkg --add-architecture i386
sudo apt-get update

sudo apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386

#setup the KVM (virtual machine)

#verify kvm is funtional before running android studio setup.

#http://sharadchhetri.com/2014/10/09/install-kvm-kernel-based-virtual-machine-ubuntu-14-04-lts-desktop/

#https://help.ubuntu.com/community/KVM/Installation

sudo apt-get install qemu-kvm libvirt-bin bridge-utils
sudo apt-get install virt-manager
sudo apt-get install qemu-system

#logout or reboot

#start studio by opening termainal and run studio.sh

#update the sdk and add emulators


https://gist.github.com/anonymous/d305c68ea5d182a20f06#file-android_studio_on_ubuntu

Friday, July 11, 2014

Trommel rock separator

Trommel are very handy when you have very rocky soil.  A good instructables here Trommel.







Monday, January 27, 2014

DIY PVC-IKEA Treadmill Desk - Again

Wanted to make another desk and needed to simplify the construction.  This desk uses all 1.5 inch PVC tube and fittings and only requires cutting the tubes.

Went back to Ikea with some of the PVC parts and re-though the connections.  The metal table legs fit perfectly into the 1.5 inch PVC pipe. 

To tighten the connection between the table leg and the PVC make a vertical cut at the end of the pipe and push a coupling down.  The coupling will apply pressure and jamb the PVC against the metal leg.  

The angle brace is 1 inch PVC with a elbow connection.  Drilled a hole in the elbow and used a drywall screw to fasten the main brace bar.  Drywall screws where also used on the other two locations. 

IKEA:

Table top: LINNMON  $16
Legs:  LINNMON/ ADILS   4 @ $3.5 per leg

PVC:

2@ 10 foot 1.5 inch PVC40
4@ 1.5 inch coupling
4@ 1.5 inch elbow
2@ 1.5 inch tee

Odds and ends:

3@ 2 inch drywall screws.

PVC angle brace could be 3/4 inch tube with a single elbow connection.

Tools:

Miter box saw is handy to create nice clean cuts.
A cordless drill / screwdriver is handy.
Tape measure.
Level to adjust table finished height.


Wednesday, August 28, 2013

DIY PVC-IKEA Treadmill Desk

DIY PVC-IKEA Treadmill Desk

check out the latest version


Built this treadmill desk for about a hundred bucks.  Gets me up and walking while I work which has been great.

Used 2 and 1.5 in PVC.  The legs extend for height adjustment.  Ikea sells the desk part for 15 bucks and the leg attachments I found in the 1/2 off bin.  Didn't end up needing Ts for the feet and could have just used a 90 degree elbow.  Routing out the 1.5 to 2 in reducer for each leg was difficult and would recommend a sanding brush drill bit to do the job.

A couple months have passed....

Recently I added some http://store.hermanmiller.com/  Flo Monitor Supports.  They are lightweight and easy to attach.