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.