Ask Your Question

antonimaco's profile - activity

2016-09-02 05:16:28 -0600 asked a question How to show OpenCV video in OpenGL window

Hello, I'm looking for the way to show in a openGL window the video signal that I'm capturing from my ip camera with openCV. The reason that I need this is, because when the openGL window is activated I can send HTTP commands to my camera to move it with keyboard cursos.

I show you my code below, both OpenCV and OpenGL work perfectly independent, but I would like to integrate both. So you can see the video signal while you are moving it. Can you let me know how I can do this. I'm very new with OpenGL and OpenCV.

Thanks in advance.

#include "curlpp/cURLpp.hpp"
#include "curlpp/Options.hpp"


#include <opencv2/highgui/highgui.hpp>
#include <stdio.h>
#include <sstream>
#include <iostream>
#include <GLUT/glut.h>


using namespace std;


//Inicio curl
curlpp::Cleanup myCleanup;

std::ostringstream os;

 //process menu option 'op'
void menu(int op) {

    switch(op) {
        case 'Q':
        case 'q':
            exit(0);
    }
}

//executed when a regular key is pressed
void keyboardDown(unsigned char key, int x, int y) {


    switch(key) {
        case 'Q':
        case 'q':
        case  27:   // ESC
            exit(0);
    }
}

//executed when a regular key is released
void keyboardUp(unsigned char key, int x, int y) {

}



//executed when a special key is pressed
void keyboardSpecialDown(int k, int x, int y) {





    switch(k)
    {
        case GLUT_KEY_UP:
            {
            //Mueve la camara hacia la arriba
            os << curlpp::options::Url("http://192.168.1.90/axis-cgi/com/ptz.cgi?move=up");
            }
            break;
        case GLUT_KEY_DOWN:
            {
            //Mueve la camara hacia la abajo
            os << curlpp::options::Url("http://192.168.1.90/axis-cgi/com/ptz.cgi?move=down");
            }
            break;
        case GLUT_KEY_LEFT:
            {
            //Mueve la camara hacia la izquierda
            os << curlpp::options::Url("http://192.168.1.90/axis-cgi/com/ptz.cgi?move=left");
            }
            break;

        case GLUT_KEY_RIGHT:
            {
            //Mueve la camara hacia la derecha
            os << curlpp::options::Url("http://192.168.1.90/axis-cgi/com/ptz.cgi?move=right");
            }
            break;
    }

}

//executed when a special key is released
void keyboardSpecialUp(int k, int x, int y) {

}

//reshaped window
void reshape(int width, int height) {

    GLfloat fieldOfView = 90.0f;
    glViewport (0, 0, (GLsizei) width, (GLsizei) height);

    glMatrixMode (GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(fieldOfView, (GLfloat) width/(GLfloat) height, 0.1, 500.0);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}




//render the scene
void draw() {

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    //render the scene here

    glFlush();
    glutSwapBuffers();
}

//executed when program is idle
void idle() {

}

//initialize OpenGL settings
void initGL(int width, int height) {

    reshape(width, height);

    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glClearDepth(1.0f);

    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);
}

//initialize GLUT settings, register callbacks, enter main loop
int main(int argc, char** argv) {


    //RECIBIR SEÑAL DE LA CAMARA

    cv::VideoCapture camera;
    camera.open("http://192.168.1.90/axis-cgi/mjpg/video.cgi?.mjpg");

    if (camera.isOpened()==true)
    {
        cv::namedWindow("camera");
        int key = 0;
        while (key != 27)
        {
            cv::Mat_<cv::Vec3b> image;
            camera.grab();
            camera.retrieve(image);
            cv::imshow("camera",image);
            key = cv::waitKey(10);

        }
    }
    else{
        printf("No se puede leer la senal");
    }

    //cv::setOpenGlContext("camera");


    //CONTROL DE LA CAMARA



    glutInit(&argc, argv);

    glutInitDisplayMode ...
(more)
2016-08-26 04:43:39 -0600 asked a question face tracking with ip camera

Hello everyone,

I'm new with opencv and I'm developing an opencv project to performance a face detection. I have already reached the face detection with my axis ip camera but now, I would like to track the camera to the posittion of the face marker in the opencv window, when the user is moving around. So what I want to do is: continuously check if the face detection marker(an ellipse) is centered in the image showed and if it's not centered, move the camera(sending the proper HTTP command to the camera).

My question is : Is there any way to check if the ellipse marker of the face detection is centered in the image showed??

Thanks in advance!!

2016-08-19 07:41:11 -0600 answered a question How do I access an IP Camera?

I'm new in this forum so first of all: Hi everyone and thanks in advance for your help.

I'm currently developing a c++ project (Xcode project over mac osx) with opencv to process an "axis v59" ip camera. I have problems to connect my aplicattion with the camera. This is the code I'm using:

cv::VideoCapture camera; camera.open("http://192.168.0.90/axis-cgi/mjpg/video.cgi"); if (camera.isOpened()==true) { cv::namedWindow("camera"); int key = 0; while (key != 27) { cv::Mat_<cv::vec3b> image; camera.grab(); camera.retrieve(image); cv::imshow("camera",image); key = cv::waitKey(10);

    }
}
else{
    printf("No se puede leer la senal");
}

When I execute the code I obtain this: "WARNING: Couldn't read movie file http://192.168.0.90/axis-cgi/mjpg/vid...

The camera is configurated to not need user and password for viewer login. I have tried to recibe that url from VLC and from my browser and it works perfectly.

Do you have any idea of wha I'm doing wrong??

Thanks!!