Monday, January 14, 2013

Camera Connections

IEEE 1394 (Firewire)

Pros

  • Simple daisy chaining capability


Cons
  • Slower data transfer - up to 400Mbps/800Mbps
  • No onboard memory for saving images
  • Difficult to synchronize with other devices
GigE (Gigabit Ethernet)

Pros
  • Faster transfer rates - up to 1000Mbps
  • Can be deployed to remote network-connected locations
Cons
  • Less triggering support
  • Difficult to synchronize with other devices
USB 2.0
  • Slower data transfer - up to 480Mbps
USB 3.0
  • High speed, high pixel depth and large image file sizes
  • Plug and play capability

Monday, October 22, 2012

PCA Dimension Reduction In Matlab


X = columnwise_vector';
%row-wise [X rows are the number of samples and cols are the number of dimensions]

C = mean(X);
X = X - repmat(C, size(X,1),1); %normalize by removing mean

covar = cov(X); %compute covariance matrix

[p,D]=eigs(covar, numDim);

X_reduced = (X*p);
X_reduced = X_reduced';

Friday, October 19, 2012

Hardware synchronizing a stereo rig of ps3 eye usb cameras

2 Links:

http://www.instructables.com/id/The-EyeWriter-20/?ALLSTEPS
http://nuigroup.com/forums/viewthread/12445/#66879

Thursday, October 18, 2012

Viewing stereo usb cameras on ROS

Download and install the uvc_camera drivers

Edit the uvcCameraLaunch.launch to contain the following:
<!--xml-->
<launch>
      <node pkg="uvc_camera" type="stereo_node" name="uvc_camera_stereo">
        <param name="width" type="int" value="320" />
        <param name="height" type="int" value="240" />
        <param name="fps" type="int" value="30" />
        <param name="frame" type="string" value="wide_stereo" />
    <param name="right/device" type="string" value="/dev/video1" />
        <param name="left/device" type="string" value="/dev/video2" />
     </node>
</launch>

launch this stack by:  ROS_NAMESPACE=stereo roslaunch UAVcam uvcCameraLaunch.launch

View the published messages: rostopic list
make sure the ros_namespace precedes the /left and /right image stream messages.

To view each stream:
$ rosrun image_view image_view image:=/stereo/left/image_raw
$ rosrun image_view image_view image:=/stereo/right/image_raw 
If you have a built-in webcam, I disabled it using the following:
by adding "blacklist uvcvideo" to the end of the file /etc/modprobe.d/blacklist.conf
I made sure uvcvideo was the name of the driver being used for this webcam using hwinfo 
(you must restart for the webcam to be disabled)
 
Then run the camera_calibration.
http://www.ros.org/wiki/camera_calibration/Tutorials/StereoCalibration 
 
 
 
 




Wednesday, October 17, 2012

ps3 eye usb camera and ROS

How to work with playstation ps3 eye USB camera and ROS and OpenCV

http://siddhantahuja.wordpress.com/2011/07/20/working-with-ros-and-opencv-draft/

For stereo:
https://code.ros.org/gf/project/ros/mailman/?_forum_action=ForumMessageBrowse&thread_id=55017&action=ListThreads&mailman_id=20

roscd: command not found

Problem:
roscd: command not found

Solution:
To solve this problem you must define the source of the ros setup.bash file:
Execute:

- source /opt/ros/fuerte/setup.bash
- source ~/ros_workspace/setup.bash 

(the second one made all warnings go away - use this instead of the first one. With the first one, I still got some warnings when I typed roscd with no arguments) 

in a terminal. In my case I was working ROS Fuerte (version 1.8.10).

this happened because I didnt do the last steps of installing ROS.

For a permanent fix edit .bashrc (use 'gedit .bashrc" for editing)and add the following to the end of the file:

export ROS_WORKSPACE=/home/anubis/fuerte_workspace









notice that we changed the ros workspace name (from ros_workspace to fuerte_workspace)

Friday, September 7, 2012

Setting Mat Pixels (elements) in OpenCV


This is how you set individual element's color channels of a Mat structure in OpenCV

img.at<cv::Vec3b>(v,u)[0]=B;
img.at<cv::Vec3b>(v,u)[1]=G;
img.at<cv::Vec3b>(v,u)[2]=R;

Thursday, August 9, 2012

Play Video in OpenCV

This is with the older OpenCV versions. I had problems using the new OpenCV 2.4.0 so I resorted to this older way of reading videos. It can also be used in the later OpenCV versions (i.e. they are backward compatible)


/* play a video file */

#include <highgui.h>

int main(int argc, char** argv) {
    /* Create a window */
    cvNamedWindow("Example2", CV_WINDOW_AUTOSIZE);
    /* capture frame from video file */
    CvCapture* capture = cvCreateFileCapture( argv[1]);
    /* Create IplImage to point to each frame */
    IplImage* frame;
    /* Loop until frame ended or ESC is pressed */
    while(1) {
        /* grab frame image, and retrieve */
        frame = cvQueryFrame(capture);
        /* exit loop if fram is null / movie end */
        if(!frame) break;
        /* display frame into window */
        cvShowImage("Example2", frame);
        /* if ESC is pressed then exit loop */
        char c = cvWaitKey(33);
        if(c==27) break;
    }
    /* destroy pointer to video */
    cvReleaseCapture(&capture);
    /* delete window */
    cvDestroyWindow("Example2");

    return EXIT_SUCCESS;
}

Adding OpenCV to Eclipse

Adding OpenCV to Eclipse:


  1. Download eclipse indigo or the latest C++ IDE version
  2. Create a project
  3. Properties > C/C++ Build > Settings. 
  • Under Libraries add "opencv_core", "opencv_cv" and all OpenCV libraries you will need
  • Under "Library Search Path" add the location of the built libraries, usually: "/usr/local/lib" on Mac
  • Under Includes add the path to the include header files (.h), usually: "usr/local/include/opencv"



Tuesday, September 25, 2007

Thursday, May 17, 2007

Hybridizing ACO and PSO

My masters thesis topic:

“Applying aspects of the ACO paradigm to PSO to create an improved algorithm to solve combinatorial optimization problems with better performance”

525

Just a number? Hardly a number! Its the number to a course. Its not just a course. Its more. CSCI 525 is a graduate (master's degree) course given in The American University in Cairo.

This course has been the most mind-boggling course I have ever taken. It has been one of the hardest and most demanding. At the same time it has been very displeasing. On the other hand I don't think I have ever enjoyed a course like this. It has been so challenging to the extent my mind was not powerful enough. LOL, I find this relevant to the subtitle of my blog: "An insight into a mind. A powerful tool, but only when tamed". Despite the tiring mind-boggling stress I managed to pull off a good grade in the second midterm. I was pleased with this...el humdulilah. There is still the daunting task of preparing for the final exam which is comprehensive and writing a literature survey paper of the Weighted Max-Sat problem. The person who writes the best paper will win a bump up in his end grade. WOW, I would love that. Fortunately and unfortunately I'm up against a lot of competition and im short of time since I have another final next week.

Life is hardship. If things came easy, there would be no self-pride and success...

ACO

Ant Colony Optimization: An algorithm for solving combinatorial optimization...

Thursday, March 1, 2007

overloading & overriding

Overriding is when you override an inherited method in a subclass.
Overloading is when you create many methods with the same signature, except the parameters are different (same name but different parameters).

the signature of a method (in Java) is the method name and the number and types of parameters.

Monday, January 22, 2007

Test-driven development

1. Add a test
Each new feature begins with writing a test.

2. Run all tests and see the new one fail
This validates that the new test does not mistakenly pass without requiring any new code. The new test should also fail for the expected reason. This step ensures the test will require the right behavior: it tests the test itself, in the negative.

3. Write some code
The next step is to write some code that will pass the new test.

4. Run the automated tests and see them succeed

5. Refactor code
Now the code can be cleaned up as necessary. By re-running the test cases the developer can be confident that refactoring is not damaging any existing functionality. The concept of removing duplication is an important aspect of any software design. In this case, however, it also applies to removing any duplication between the test code and the production code.

Boxing and unboxing in C#

Boxing and unboxing is an essential concept in C#. With Boxing and unboxing one can link between value-types and reference-types by allowing any value of a value-type to be converted to and from type object. Boxing and unboxing enables a unified view wherein a value of any type can ultimately be treated as an object. Converting a value type to reference type is called Boxing. Unboxing is an explicit operation.

C# provides a unified type system. All types including value types derive from the type object. It is possible to call object methods on any value, even values of primitive types such as int.

Example:

class Test
{
static void Main() {
Console.WriteLine(3.ToString());
}
}


class Test
{
static void Main() {
int i = 1;
object o = i; // boxing
int j = (int) o; // unboxing
}
}


The above example shows both boxing and unboxing. When a variable of a value type needs to be converted to a reference type, an object box is allocated to hold the value, and the value is copied into the box. A boxing conversion permits any value-type to be implicitly converted to the type object or to any interface-type implemented by the value-type. Boxing a value of a value-type consists of allocating an object instance and copying the value-type value into that instance.

Unboxing is just the opposite. When an object box is cast back to its original value type, the value is copied out of the box and into the appropriate storage location.

Mutex

A MUTEX is a mutual exclusion algorithms used in concurrent programming to avoid the simultaneous use of a common resource, such as a global variable, by pieces of computer code called critical sections.

Examples of such resources are flags, counters or queues, used to communicate between code that runs concurrently, such as an application and its interrupt handlers. The problem is acute because a thread can be stopped or started at any time.

A mutex is also a common name for a program object that negotiates mutual exclusion among threads, also called a lock.

Saturday, January 20, 2007

Tuesday, January 16, 2007

Hofstadter's law

A very interesting adage. I'm not sure how you pronounce the guy's name but the saying goes like this:

It always takes longer than you expect, even when you take into account Hofstadter's Law.

Do you see the recursion in it? This is a self-referencing adage by Douglas Hofstadter. It is often cited among programmers, especially in discussions of techniques to improve productivity. Hofstadter's Law is a profound statement of the difficulty of accurately estimating the amount of time it will take to complete tasks of any substantial complexity.

Even after you have taken Hofstadter's Law into account, by Hofstadter's Law you must still take Hofstadter's Law into account, and this remains true no matter how many times you have already applied Hofstadter's Law.

It is therefore impossible to ever fully take Hofstadter's Law into account, at least in finite time. While some recursive functions do seem to eventually converge on an approximate solution (e.g., x/2 approaches zero when its output is repeatedly fed back into it), anyone who has attempted to manage a software project can testify that this does not seem to be true of Hofstadter's Law; if anything, estimates that take Hofstadter's Law into account even partially seem to have an infinite, or at least very large, upper bound. Thus, Hofstadter's Law implies that it is not merely difficult to estimate a project—it is potentially infinitely difficult

A (somewhat joking) rule of thumb introduced by Hofstadter for calculating an approximate time is to double the number and step up to the next higher units. For example, a job estimated at 1 hour can be accomplished in 2 days, while a 3-month project will take you 6 years.

PS: finite difficulty: requires that the extra difficulty decrease quickly enough for the recursive series to converge to a finite value in finite time).

SOA

Service-oriented Architecure is an architectural and design style and paradigm in software engineering. Its primary intent is to align business with IT to create an on-demand or more flexible IT infrastructure. SOA is all about services, reuse, integration and open standards. SOA defines a different approach to software engineering. It involves what is called SOA Governance which is a model which defines the processes and policies for managing and overseeing the SOA structure. It measures how the business's current state is compared to it's business goals. SOA is usually, but not always, implemented using web services.