Showing posts with label Tutorials. Show all posts
Showing posts with label Tutorials. Show all posts

Sunday, June 26, 2011

MTK NMEA checksum calculation

The MTK NMEA checksum can be calculated by using the following procedure:

The NMEA Checksum is calculated on a character by character basis using an XOR operator. Each character is fed into an XOR with the current checksum value. The checksum is initialized to all zeros. The characters that exist between the "$" and "*" are the only characters to be used in the calculation. These values are in ASCII, thus each character is represented as an 8-bit value. The resulting checksum is an 8-bit HEX value which is represented as 2 ASCII characters. Below is an example of this procedure:

$PMTK000*32


0000 0000 <==Checksum
0101 0000 <==P

0101 0000 <==Checksum
0100 1101 <==M

0001 1101 <==Checksum
0101 0100 <==T

0100 1001 <==Checksum
0100 1011 <==K

0000 0010 <==Checksum
0011 0000 <==0

0011 0010 <==Checksum
0011 0000 <==0

0000 0010 <==Checksum
0011 0000 <==0

0011 0010 <==Checksum

This results in a checksum of 32 which matches what was shown above.

And for those folks that use MATLAB, HERE is a very basic program that I wrote up that does this for you.

Enjoy!

Monday, May 2, 2011

Setting up OpenCV in Eclipse on Windows (OpenCV2.2)

The latest release of OpenCV (version 2.2) has undergone dramatic changes to the library. Because of these changes, my older guide is now outdated. For OpenCV version 2.2, please use this guide.

First download and setup the basics:
  • Get MinGW
  • Download Eclipse C/C++ IDE
Note: I have a tutorial on these two steps already so just head over HERE for more info.

  • Next download/install OpenCV 2.2
  • Now launch Eclipse and start a new project by going to:
  1. File->New->C++ Project (or File->New->C Project)
  2. Give your project a name in the "Project name" box
  3. Select the "Hello World" option under the "Project Type" section under the"Executable" folder. I recommend this over the "Empty Project" as it creates the c/c++ file for you instead of having to do it manually (it also creates a "src" folder and a"Debug" folder which helps keep things a little more organized)
  4. Make sure the "MinGW" Toolchain is selected in the "Toolchains" section
  5. Hit NEXT
  6. Fill in your Author and other file information, then hit NEXT
  7. In the next window select "Advanced settings...". This will bring you to the "Project Settings" which can always be accessed later by going to Project->Properties
  8. Under the "C/C++ Build" Section go to the "Settings" and select the "Tool Settings"Tab. Then select the "Includes" folder (on older versions of eclipse it is the "Directories" folder) in the GCC Compiler branch and add the opencv include directory to Include paths (-I): "C:\OpenCV2.2\include\". Of course, change C:\OpenCV2.2 to match the installed path that you used.
  9. Now, under the MinGW Linker select the "Libraries" folder and add the following to the Libraries (-l) section (note not all of these are necessarily needed for your project but these are all the libraries available in opencv version 2.2):
  • opencv_calib3d220
  • opencv_contrib220
  • opencv_core220
  • opencv_features2d220
  • opencv_ffmpeg220
  • opencv_flann220
  • opencv_gpu220
  • opencv_highgui220
  • opencv_imgproc220
  • opencv_legacy220
  • opencv_ml220
  • opencv_objdetect220
  • opencv_ts220
  • opencv_video220
In most cases you will only need opencv_core220 and opencv_highgui220 to get started

NOTE: Versions 2.2 and later postfix the libraries names with a three digit number that corresponds to the version of OpenCV that you are linking to.

FINALLY, under the "Library search path (-L)" section add:
  • "C:\OpenCV2.2\lib"
  1. Hit OK when done
  2. Hit Finish to create and start the Project
Write up a simple program to test if opencv works properly. You can use this EXAMPLE CODE I made to test if your video camera and environment are working properly.

NOTE: The way this guide was written will require you to use a relative path to specify the header files you wish to include. OpenCV breaks up the library into two sections, "legacy libraries" and "new libraries".

If you wish to specify one of the new opencv libraries use the following format:

#include "opencv2\[subfolder]\[library.hpp]"

ADDITIONALLY, if you wish to include all of the primary opencv2 header files in a project you can use:

#include "opencv2\opencv.hpp"

Note: opencv.hpp does not include every library in OpenCV2.2. It may be helpful for you to view the "opencv.hpp" library (located by default in: C:\OpenCV2.2\include\opencv2\opencv.hpp) to see what is included and how you can reference the new libraries in your code. To see the complete list of libraries available, go to "C:\OpenCV2.2\include\" and browse around the directory.

Legacy libraries can be defined by: #include "opencv\[library.hpp]"


If you get an error, during compile time, pertaining to:
__exchange_and_add
Then visit this page and follow the instructions under:
Building on Windows using MinGW 3.4.5

Hope this helps!

Wednesday, June 9, 2010

Creating/Adding an NFS Share

A couple days ago I had to create an NFS share at work. I never had to create one before but I found it to be quite painless. Here's how I did it in Sabayon Linux:

1. Start the nfs daemon if it is not already launched:
#/etc/init.d/nfs start

2. Edit the /etc/exports file (create it if needed) to include the share you wish to allow access to using the following syntax:

[full_path_to_share] [client_ip] ([privalages])


Example:

/home/aether/share 192.168.64.100 (rw)


3. Update the exports by running:
#exportfs -rv


Note: you may see some output warnings, but it will most likely still work.

4. You should now be able to mount the nfs share on the client

Thursday, April 1, 2010

Sabayon Kernel Upgrade Procedure

For those that know me, you probably have heard me talk about Sabayon and praise it for its flexibility, hardware support, good looks, humor (yes humor...see below for a nice April's Fools joke), and most importantly ease of use.


One of the nice things about Sabayon is that the kernel updating is quiet simple, given the complexities involved with the kernel. Below I outline a general procedure to help avoid any headaches one might have when updating their kernel.

1. Grab a list of drivers that will need to be updated:
#equo query installed $(uname -r)

2. Download/Install the kernel:
#equo install sys-kernel/linux-sabayon

3. Install all packages listed in Step 1 (make sure to remove the version info otherwise you will just reinstall the current outdated package)

4. Verify that the kernel is selected:
#eselect kernel list

5. If the new kernel is not selected with '*', set it with:
#eselect kernel set [NUMBER]

6. Also make sure opengl has the correct driver selected with:
#eselect opengl list

7. Correct the opengl selection as needed with:
#eselect opengl set [NUMBER]

8. Make the new kernel the default option in grub (if so desired) by going to /boot/grub/menu.lst

9. Inside menu.lst change "default" to the the corresponding option.

10. It is also a good idea to run a dependency test and library test with:
#equo deptest
#equo libtest

And you should be good to go...NOT SO DIFFICULT IS IT?

Thursday, February 4, 2010

Setting up OpenCV in Eclipse on Windows

IF YOU ARE INSTALLING OPENCV VERSION 2.2 OR LATER PLEASE GO HERE INSTEAD: OpenCV 2.2 GUIDE.

Recently OpenCV 2.0 was officially released. For those looking to do an upgrade to 2.0 (OR LATER) or installing OpenCV for the first time, there are some discrepancies with how older sites say you should setup your environment. I did some file digging and this is what I found works:

First download and setup the basics:
  • Get MinGW
  • Download Eclipse C/C++ IDE
Note: I have a tutorial on these two steps already so just head over HERE for more info.

  • Next download/install OpenCV 2.0 (OR download a more recent version)
  • Now launch Eclipse and start a new project by going to:
  1. File->New->C++ Project (or File->New->C Project)
  2. Give your project a name in the "Project name" box
  3. Select the "Hello World" option under the "Project Type" section under the "Executable" folder. I recommend this over the "Empty Project" as it creates the c/c++ file for you instead of having to do it manually (it also creates a "src" folder and a "Debug" folder which helps keep things a little more organized)
  4. Make sure the "MinGW" Toolchain is selected in the "Toolchains" section
  5. Hit NEXT
  6. Fill in your Author and other file information, then hit NEXT
  7. In the next window select "Advanced settings...". This will bring you to the "Project Settings" which can always be accessed later by going to Project->Properties
  8. Under the "C/C++ Build" Section go to the "Settings" and select the "Tool Settings" Tab. Then select the "Includes" folder (on older versions of eclipse it is the "Directories" folder) in the GCC Compiler branch and add the opencv include directory to Include paths (-I): "C:\OpenCV2.0\include\opencv\". Of course, change C:\OpenCV2.0 to match the installed path that you used.
  9. Now, under the MinGW Linker select the "Libraries" folder and add the following to the Libraries (-l) section (note not all of these are necessarily needed for your project but these are all the libraries available in opencv):
  • cv200
  • cvaux200
  • cxcore200
  • cxts200
  • highgui200
  • ml200
In most cases you will only need cv200 and highgui200 to get started

ALSO NOTE: Versions 2.0 and later postfix the libraries names with a three digit number that corresponds to the version of OpenCV that you are linking to. Example: OpenCV2.1's highgui library must be linked using the name highgui210.

FINALLY, under the "Library search path (-L)" section add:
  • "C:\OpenCV2.0\lib"
  1. Hit OK when done
  2. Hit Finish to create and start the Project
Write up a simple program to test if opencv works properly. You can use this snippet of code I made to test if your video camera and environment are working properly. I would have posted the code here, but blogger is being very difficult with the c++ syntax (i.e. it is trying to read a lot of things as html tags).

If you get an error, during compile time, pertaining to:
__exchange_and_add

Then visit this page and follow the instructions under:
Building on Windows using MinGW 3.4.5

Hope this helps!

Tuesday, November 24, 2009

SSH X11 Forwarding

Here's a nice little trick for SSH users. Did you know that you can forward X11 traffic through an SSH connection? All you got to do is this:

If your SSH'ing to a linux machine from a linux machine just issue the command:

# ssh -X username@ipaddress


If your SSH'ing to a linux machine from a Windows machine you need get the following:
Xming X Server
PuTTY

You might also need to install some fonts found here (I however didn't need to do this):
Fonts

  • Now just install Xming and the Fonts (if the Fonts are needed) into the default directory.
  • Then launch PuTTY and enter in the username@ipaddress into the "Host Name" field
  • Go to the Connection>SSH>X11 section in PuTTY and check the "Enable X11 forwarding" option
  • Also, if needed, set the "X display location" to localhost:0

Once you connect you will be able to issue commands in the command line as you would normally but also run programs that have a GUI. A really cool feature is that the windows are created in your local OS unlike VNC and RDP where the windows are bound inside the Remote Desktop Application window.

Note: The SSH Deamon running on the server might need to be configured to allow X11 Forwarding. Just do a google search to get this information (it generally just requires you to uncomment a line in a configuration file).

Enjoy