Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

asked 2015-08-16 02:41:34 -0600

Nbb gravatar image

openMP imshow

Hi forum,

I am having a problem trying to show multiple videos using openmp. Below is the code

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "opencv2/imgproc/imgproc.hpp"
#include "omp.h"
#include <iostream>

using namespace cv;
using namespace std;

string Camera[2] = { "camA.avi", "camB.avi" };

int main(int argc, const char * argv[])
{
    omp_set_num_threads(2);
    Mat frame;

    #pragma omp parallel private (frame)
    {
        VideoCapture capture;

        int Thread = omp_get_thread_num();

        capture.open(Camera[Thread]);

        while (1){
            capture.read(frame);

            namedWindow(Camera[Thread], CV_WINDOW_NORMAL);
            imshow(Camera[Thread], frame);
            waitKey(1);
        }

    }

}

I just wanna be able to display both videos at the same time. Hope I can get some help. Thanks

openMP imshow

Hi forum,

I am having a problem trying to show multiple videos using openmp. Below is the code

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "opencv2/imgproc/imgproc.hpp"
#include "omp.h"
#include <iostream>

using namespace cv;
using namespace std;

string Camera[2] = { "camA.avi", "camB.avi" };

int main(int argc, const char * argv[])
{
    omp_set_num_threads(2);
    Mat frame;

    #pragma omp parallel private (frame)
    {
        VideoCapture capture;

        int Thread = omp_get_thread_num();

        capture.open(Camera[Thread]);

        while (1){
            capture.read(frame);

            namedWindow(Camera[Thread], CV_WINDOW_NORMAL);
            imshow(Camera[Thread], frame);
            waitKey(1);
        }

    }

}

I just wanna be able to display both videos at the same time. Hope I can get some help. Thanks

EDIT: So I added in a few lines of code which has no relation to the parallel threads and I got it running... Now im even more confused.

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "opencv2/imgproc/imgproc.hpp"
#include "omp.h"
#include <iostream>

using namespace cv;
using namespace std;

string Camera[2] = { "filmrole3.avi", "filmrole4.avi" };


int main(int argc, const char * argv[])
{
    omp_set_num_threads(2);

    FileStorage fs("Cam3_Homography.yml", FileStorage::READ);
    vector<Mat> Homography_Matrix(2);
    fs["Cam3_Homography"] >> Homography_Matrix[0];
    fs.release();


    #pragma omp parallel
    {
        VideoCapture capture;
        Mat frame;

        int Thread = omp_get_thread_num();

        capture.open(Camera[Thread]);

        while (1){
            capture.read(frame);

            namedWindow(Camera[Thread], CV_WINDOW_NORMAL);
            imshow(Camera[Thread], frame);
            waitKey(1);
        }

    }

}