Cross-compile latest Tensorflow (1.5+) for the Nvidia Jetson TK1

Been looking around for a solid resource on how to get Tensorflow to run on the Jetson TK1. Most what I found was how to get TF 0.8 to run, which was the last TF version to allow usage of cuDNN 6 that is the latest version available for the TK1.

The TK1 is an aging platform with halted support, but it is still a cheap option for high-powered embedded compute. Unfortunately, being so outdated it's impossible to get the latest and greatest of DNN to work on the CUDA GPU on the TK1, but we can certainly use the CPU!
So a word of disclaimer - this compiled TF version will not use the GPU, just the CPU. However, it will let you run the most recent NN architectures with the latest layer implementations.

Cross compilation for the TK1 solves the acute problem of space on the device itself, as well as speed of compilation. On the other hand it required bringing up a compilation toolchain, which took a while to find.

I am going to be assuming a Ubuntu 16.04 x86_64 machine, which is what I have, and really you can do this in a VM or a Docker container just as well on Windows.

Continue reading "Cross-compile latest Tensorflow (1.5+) for the Nvidia Jetson TK1"


FFMpeg with Lame MP3 and streaming for the Arduino Yun

So, I've been trying to stream audio off of a USB microphone connected to an Arduino Yun.
Looking into it online I found some examples using ffserver & ffmpeg, which sounded like they could do the trick.
However right from the start I've had many problems with playing the streams on Android and iOS devices.
Seems Android likes a certain list of codecs ( and iOS like a different set of codecs (Link here), but they do have on codec in common - good ol' MP3.
Unfortunately, the OpenWRT on the Arduino Yun has an ffmpeg build which does not provide MP3 encoding... it does have the MP3 muxer/container format, but streaming anything other then MP3 in it (for example MP2, which the Yun-ffmpeg does have) simply doesn't work on the Android/iOS.
From experiments streaming from my PC a ffmpeg/libmp3lame MP3 stream, it looks like the mobile devices are quite happy with it - so I will need to recompile ffmpeg with Lame MP3 support to be able to stream it.
Continue reading "FFMpeg with Lame MP3 and streaming for the Arduino Yun"


Tailing the output of multiple files in Linux

This is a quick post to show a trick to tail multiple files, while showing the filename in the beginning of the line

What I needed was a way to grep multiple logs for an exception. But doing "tail -f *.log | grep exception" only let me see the exception, but I didn't know which log file to look in

I have found this guide, and altered the script and added

  1. Printing the file name in the beginning of each line
  2. Padding spaces after the file name (you can alter the minimal length in the ALIGN variable

Anyway - here's the script. Hope you find it useful

# When this exits, exit all back ground process also.
trap 'kill $(jobs -p)' EXIT
# iterate through the each given file names,
for file in "$@"
        LENGTH=<code>echo ${file} | wc -c</code>
        PADDING=<code>expr ${ALIGN} - ${LENGTH}</code>
        PAD=<code>perl -e &quot;print ' ' x $PADDING;&quot;</code>
        # show tails of each in background.
        tail -f $file | sed &quot;s/^/${file}${PAD}:/g&quot;  &amp;
# wait .. until CTRL+C

A Creative way to bypass Pattern lock on Android

Let me start putting everything on the table – this post will describe how I eventually managed to unlock an unrooted, non-Google account linked Samsung Galaxy Mini Plus (GT-5570I) device without ADB support. There are a lot of guides on how to bypass this pattern lock on Android (and I will provide some links), but the purpose of this post is to show how looking for creative ways to do this can come handy

So a friend gave me a locked device. This device had no Google account linked to it (which prevented me from bypassing the lock with that account), there was no root or ADB access via recovery, and the USB debugging option was disabled.

I found this guide here, which states some commands you can type in ADB shell and should deactivate the pattern lock. So – How do I get ADB access on that phone? Continue reading "A Creative way to bypass Pattern lock on Android"


Reading a directory in C++ (Win32 & Posix)

Just a snippet of code if someone out there needs it. I keep coming back to it, so I thought why not share it...

#include <iostream>

#ifndef WIN32
#include <dirent.h>

using namespace std;

void open_imgs_dir(char* dir_name, std::vector<std::string>& file_names) {
	if (dir_name == NULL) {

	string dir_name_ = string(dir_name);
	vector<string> files_;

#ifndef WIN32
//open a directory the POSIX way

	DIR *dp;
	struct dirent *ep;     
	dp = opendir (dir_name);
	if (dp != NULL)
		while (ep = readdir (dp)) {
			if (ep->d_name[0] != '.')
		(void) closedir (dp);
	else {
		cerr << ("Couldn't open the directory");

//open a directory the WIN32 way
	WIN32_FIND_DATA fdata;

	if(dir_name_[dir_name_.size()-1] == '\\' || dir_name_[dir_name_.size()-1] == '/') {
		dir_name_ = dir_name_.substr(0,dir_name_.size()-1);

	hFind = FindFirstFile(string(dir_name_).append("\\*").c_str(), &fdata);	
			if (strcmp(fdata.cFileName, ".") != 0 &&
				strcmp(fdata.cFileName, "..") != 0)
				if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
					continue; // a diretory
		while (FindNextFile(hFind, &fdata) != 0);
	} else {
		cerr << "can't open directory\n";

	if (GetLastError() != ERROR_NO_MORE_FILES)
		cerr << "some other error with opening directory: " << GetLastError() << endl;

	file_names = files_;



Useful ImageMagick and FFmpeg shortcuts for Win SendTo menu


Quickly sharing some useful scripts I've "developed" over the summer to cope with some image resizing / video ripping / transcoding, etc.
Instead of using some specialized GUI software for transcoding I thought why not simply put useful options in the Windows file browser "Send To..." context menu. That way I can right-click the file I want to work with and just send it to some tool to do the job.

Here it is...
Continue reading "Useful ImageMagick and FFmpeg shortcuts for Win SendTo menu"


The Raspberry Pi is Here

A few months back I placed an order for a raspberry pi. For those who don't know what it is, it is a really cool project which is basically a computer for 35$ (Shipping for me almost doubled it, but that's to be expected). It is a board, which as 256MB Ram, SD-Card slot, 2 USB Slots, an RCA Slot for analog video, and a headphone jack for analog audio.

It is originally a project for schools, to help today's kids get started with (python, but not only) programming.

To be exact with what the project guys are describing it:

The Raspberry Pi is a credit-card sized computer board that plugs into a TV and a keyboard. It's a miniature ARM-based PC which can be used for many of the things that a desktop PC does, like spreadsheets, word-processing and games. It also plays High-Definition video.
Here are some FAQs

The OS of this board is stored on an SD Card. I have bought a class 10 16gb SD Card off of eBay for this purpose.

So few days ago, the board arrived! I finally found myself playing with it, and it's so much fun

Here are some common suggestions for usages: Continue reading "The Raspberry Pi is Here"