hi kater
ja ganz recht
normalerweise ist die webcam-ausgabe sehr fluessig
wenn die comControl arbeitet, stocken die bilder und der algo arbeitet nicht mehr
richtig.
wegen opencv + openmp
hab im netz einkleines prog gefunden
welches opencv fuer die webcams benutzt und openmp als multitasking.
ich hab gestern und heute etliche sachen mit openmp und cv versucht
ist recht komplex opencv zum mitmachen zu ueberreden
die meisten fehlermeldung waren: entweder seqfaults oder bad-frames
webcam nicht erkannt und programm abbruch.
es ist also gar nicht so einfach
vielen dank fuer deine hilfe (auch beim openmpi)
gruss nomad
ps. achtung wenn ich 2 webcams benutze -> ProgAbbruch
Code:
/*
dd. 19.07.2009
name: ompCVtest.cpp
compile:
g++ -I/usr/local/include/opencv -L /usr/local/lib -lcxcore -lcv -lhighgui -lcvaux -lml -o ompCVtest ompCVtest.cpp -lm -fopenmp
run: ./ompCVTest
Hi all,
I am currently using openmp in the computer vision. What I want to do is grab
images from to cameras. By using the parallel structure, I firstly generate two threads
using the omp sections.
The each stream from these cameras is proposed to grabbed and displayed in a corresponding thread.
I am using the opencv to grab and display images.
Once I use the series structure, i.e. images from two cameras are grabbed one by one,
there is no problem.
However, if I use the parallel structure,
I can see that two threads do work, but I can only display one image.
I am not quite sure about the problem. I need your help in this issue or any other suggestion.
I am using Xeon 2Cpu workstation with winxp system and intel cpp compiler 9.0 installed. The opencv is v4beta. The c file is shown as follows:
*/
#include <omp.h>
#include<iostream>
// openCV
#include<cv.h>
#include<cvaux.h>
#include<highgui.h>
// c
#include <math.h>
// C-Stuff for RS232
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <ctype.h>
#include <setjmp.h>
#include <termios.h>
#include <unistd.h>
#include <sys/signal.h>
#include <sys/types.h>
#include <errno.h>
#include <ctype.h>
#include <sys/io.h>
// glui
#include <sys/stat.h>
#include <stdarg.h>
#include <assert.h>
#include <float.h>
#include <limits.h>
#include <time.h>
#include <sstream>
using namespace std;
/*** special Func (1) conio.h ******************************************************************/
void gotoxy(int x, int y) { printf("\033[%d;%dH", y, x); fflush(stdout); }
void clrscr(void) { printf("\033[H\033[J"); fflush(stdout); }
// delay (nnn)
void delay(long millisek)
{
int mikrosek = millisek*1000;
struct timeval timeout;
timeout.tv_sec = mikrosek / 1000000L;
timeout.tv_usec = mikrosek % 1000000L;
select(0, NULL, NULL, NULL, &timeout);
}
/***********************************************************************************************/
int main()
{
IplImage *image1;//, *image2;
CvCapture *capture1;//, *capture2;
clock_t t1, t2;
int nframe1, nframe2, tid, nthreads;
capture1=cvCaptureFromCAM(0);
// capture2=cvCaptureFromCAM(-1);
cvNamedWindow("camera1", 1);
//cvNamedWindow("camera2", 1);
cvResizeWindow("camera1", 320, 240);
//cvResizeWindow("camera2", 320, 240);
omp_set_num_threads(4);
nframe1=0;
nframe2=0;
for (;;)
{
t1=clock();
#pragma omp parallel private(tid)
{
tid = omp_get_thread_num();
if(tid == 0)
{
nthreads=omp_get_num_threads();
printf("Number of threads = %d\n ", nthreads);
}
printf("Thread %d starting.... \n", tid);
#pragma omp sections
{
#pragma omp section
{
printf("Thread %d grabbing from camera 1 \n", tid);
image1=cvQueryFrame(capture1);
cvShowImage("camera1", image1);
printf("This is the No %d frame from camera1 \n", nframe1);
nframe1++;
}
#pragma omp section
{
printf("Thread %d ComControl\n", tid);
// image2=cvQueryFrame(capture2);
// cvShowImage("camera2", image2);
printf("Delay COM\n");
delay(500);
printf("This is the No %d frame from camera2 \n", nframe2);
nframe2++;
}
}
}
t2=clock();
printf("Time is %f \n", (double)(t2-t1)/CLOCKS_PER_SEC);
if (cvWaitKey(10)>=0)
break;
}
cvReleaseCapture(&capture1);
//cvReleaseCapture(&capture2);
cvDestroyAllWindows();
}
Lesezeichen