OpenCV

From ImageWiki

(Difference between revisions)
Jump to: navigation, search
(Eksempel 1)
Line 39: Line 39:
== Eksempel 1 ==
== Eksempel 1 ==
-
Tag billeder og vis dem.
+
billeder fra et kamera og viser dem
 +
 
 +
#include "highgui.h"
 +
 +
int main()
 +
{
 +
    // Get an OpenCV camera handle
 +
    CvCapture *cam = cvCaptureFromCAM(-1);
 +
 +
    // Initialise the GUI
 +
    const char *window = "Eksempel 1";
 +
    cvNamedWindow(window, CV_WINDOW_AUTOSIZE);
 +
 +
    // The main loop
 +
    while (cvWaitKey(4) == -1) {
 +
        IplImage *im = cvQueryFrame(cam);
 +
        cvShowImage(window, im);
 +
    }
 +
 +
    // Clean up
 +
    cvDestroyAllWindows();
 +
    cvReleaseCapture(&cam);
 +
 +
    return 0;
 +
}
 +
 
 +
 +
# Compile and link flags
 +
CXX      =  g++
 +
CXXFLAGS = `pkg-config opencv --cflags` -Wall
 +
LIBS    = `pkg-config opencv --libs`
 +
 +
# Name of executable
 +
EXECUTABLE = eksempel1
 +
 +
# Files
 +
SOURCES = eksempel1.cc
 +
OBJECTS = $(patsubst %.cc, %.o, $(SOURCES))
 +
 +
# Linking
 +
all: $(OBJECTS)
 +
$(CXX) $(LIBS) $(OBJECTS) -o $(EXECUTABLE)
 +
 +
# Compilation
 +
%.o : %.cc
 +
$(CXX) $(CXXFLAGS) -c $^
 +
 
 +
.
== Eksempel 2 ==
== Eksempel 2 ==

Revision as of 12:01, 9 July 2006

Personal tools