Tag Archives: CC BY 3.0

Flip Image OpenCV Python

OpenCV provides the flip() function which allows for flipping an image or video frame horizontally, vertically, or both.

 

Reference:

OpenCV documentation:  http://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#flip

Exploring Udacity’s 1st 40GB driving data set

I read about the release of their second data set yesterday and wanted to check it out.  For convenience, I downloaded the original, smaller, data set.

Preface: ROS is only officially supported on Ubuntu & Debian and is experimental on  OS X (Homebrew), Gentoo, and OpenEmbedded/Yocto.

Getting the data

Download the data yourself: Driving Data

The data set, which is linked to from the page above, was served up from Amazon S3 and actually seemed quite slow to download, so I let it run late last night and started exploring today.

The compressed download is dataset.bag.tar.gz

20161006-udacity-dataset-bag

and after extracting is a 42.3 GB file dataset.bag

.bag is a file type associated with the Robot Operating System (ROS)

Data overview

To get an overview of the file use the rosbag info <filename> command:

result

Open in new window

There are 28 data topics from on-board sensors including 3 color cameras.  Topics:

  • /center_camera/image_color
  • /left_camera/image_color
  • /right_camera/image_colors

Each camera topic has 15212 messages.   Doing the math on 15212 messages / 760 seconds works out to roughly 20 frames per second.

Viewing the video streams

Converting a camera topic to a standalone video is a two step process:

  1. export jpegs from the bag file
  2. convert the jpegs to video

Exporting the jpegs

To export the image topic to jpegs, the bag needs to be played back and the frames extracted.  This can be done with a launch script.  The default filename pattern (frame%04d.jpg) allows for 4 numerical figures, so we need to add the following line to modify the default file name pattern into one that allows for 5 digits:

The entire script below that launches the player and extractor:

The number of resulting frames should match the number of topic messages seen from info.

If not, as was our case, the default sec per frame time should be changed.  It seems counter-intuitive, but after slowing down the rate, trying “0.11” and “0.2”, the number of frames extracted was also going down.  I settled on “0.02” seconds per frame which resulted in the correct number of frames.  Add the line to the launch script.

The working launch script now looks like this:

Download working Left, Center, and Right jpeg export launch scripts on GitHub

The result should be the correct number of frames saved (frames starts at 00000) and the message “[rosbag-1] process has finished cleanly”

Hit Ctrl + C to exit

frame00000.jpg 640×480

20161006-udacity-self-driving-car-ds1-lc-frame00000
frame00000.jpg extracted from topic /left_camera/image_color

Convert the jpegs to video

Resources:

License: The data referenced in this post is available under the MIT license.  This post is available under CC BY 3.0

Where to next?

Udacity open sources 223GB of driving data

Following on the heels of another self-driving car developer, comma.ai releasing driving data, Udacity open sourced two data sets from their self-driving Lincoln MKZ.

Udacity’s data is over 70 minutes of driving spread over two days from Mountain View, Calif.   You can read more from the TechCrunch article or their Medium post.

The data is available under the MIT License.

We downloaded the first, smaller data set and started exploring the data.

We also have a page tracking available data sets.

License: this post is available under CC BY 3.0

Install ROS Kinetic on Ubuntu

If you haven’t heard of ROS before it is an acronym for Robot Operating System by the Open Source Robotics Foundation.

ROS provides libraries and tools to help software developers create robot applications. It provides hardware abstraction, device drivers, libraries, visualizers, message-passing, package management, and more. ROS is licensed under an open source, BSD license.

Kinetic is the tenth ROS distribution release and is short for “Kinetic Kane”.  It was released May 23rd, 2016.

 

Ubuntu install of ROS Kinetic

Debian packages are available for several Ubuntu platforms, listed below. These packages are more efficient than source-based builds and are our preferred installation method for Ubuntu. Note that there are also packages available from Ubuntu upstream. Please see UpstreamPackages to understand the difference.

Ubuntu packages are built for the following distros and architectures.

Distro amd64 i386 armhf
Ubuntu 15.10 (Wily Werewolf) X X
Ubuntu 16.04 LTS (Xenial Xerus) X X X

If you need to install from source (not recommended), please see source (download-and-compile) installation instructions.

Installation

 

Configure your Ubuntu repositories

 

Configure your Ubuntu repositories to allow “restricted,” “universe,” and “multiverse.” You can follow the Ubuntu guidefor instructions on doing this.

Setup your sources.list

 

Setup your computer to accept software from packages.ros.org. ROS Kinetic ONLY supports Wily (Ubuntu 15.10), Xenial (Ubuntu 16.04) and Jessie (Debian 8) for debian packages.

Mirrors

Source Debs are also available

 

Set up your keys

 



  •  

 

Installation

First, make sure your Debian package index is up-to-date:



  •  

There are many different libraries and tools in ROS. We provided four default configurations to get you started. You can also install ROS packages individually.

In case of problems with the next step, you can use following repositories instead of the ones mentioned above ros-shadow-fixed

  • Desktop-Full Install: (Recommended) : ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators, navigation and 2D/3D perception


    • or click here

    Desktop Install: ROS, rqt, rviz, and robot-generic libraries


    • or click here

    ROS-Base: (Bare Bones) ROS package, build, and communication libraries. No GUI tools.


    • or click here

    Individual Package: You can also install a specific ROS package (replace underscores with dashes of the package name):



    • e.g.

       

To find available packages, use:

Initialize rosdep

Before you can use ROS, you will need to initialize rosdep. rosdep enables you to easily install system dependencies for source you want to compile and is required to run some core components in ROS.

 

Environment setup

 

It’s convenient if the ROS environment variables are automatically added to your bash session every time a new shell is launched:

 

If you have more than one ROS distribution installed, ~/.bashrc must only source the setup.bash for the version you are currently using.

If you just want to change the environment of your current shell, instead of the above you can type:

 

Getting rosinstall

rosinstall is a frequently used command-line tool in ROS that is distributed separately. It enables you to easily download many source trees for ROS packages with one command.

To install this tool on Ubuntu, run:

Build farm status

The packages that you installed were built by the ROS build farm. You can check the status of individual packages here.

License

Installation how to modified from ROS wiki.  Content licensed under Creative Commons Attribution 3.0

Install OpenCV 3.x with Python 2.7 on Ubuntu

Updated: 10/11/2016

How to Install OpenCV 3.x and Python 2.7+ on Ubuntu

Step 1:

Open a terminal window and update the apt package manager lists and upgrade any currently installed packages:

Step 2:

Install developer tools:

Step 3:

Install packages to open image formats including JPEG, PNG, TIFF, and others:

Step 4:

Install the GIMP toolkit (GTK+) which OpenCV uses to build GUIs:

Step 5:

Install packages to open video formats:

Step 6:

Install libraries that optimize various routines in OpenCV:

Step 7:

Install pip, a package manager for Python:

https://pip.pypa.io/ is the official pip website

Step 8:

Install Python 2.7 development tools:

Step 9:

Install numpy because OpenCV stores images as NumPy arrays

This post follows, updates and adds to the instructions from Py Image Search here: http://www.pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu/