Ask Your Question

inckka's profile - activity

2019-09-18 07:23:01 -0600 received badge  Notable Question (source)
2019-04-09 02:47:48 -0600 received badge  Popular Question (source)
2018-11-15 05:12:05 -0600 received badge  Popular Question (source)
2017-08-09 13:44:01 -0600 received badge  Famous Question (source)
2017-04-10 07:34:11 -0600 received badge  Notable Question (source)
2017-03-14 00:46:27 -0600 received badge  Popular Question (source)
2016-03-11 02:21:05 -0600 asked a question How to capture in GRAYSCALE directly from source

I'm capturing web cam using open cv and I'd like to get direct Grayscale image from source. Below shows a sample code that I'm using for capturing video feed. Found this reference however cant see any gray scale codes. http://docs.opencv.org/2.4/modules/hi...

capture = cvCreateCameraCapture(0);
if(!capture)
    printf("Video Load Error\n");

cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640.00);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480.00);

Secondly if anyone knows how to use "CV_CAP_PROP_CONVERT_RGB" with C-API. Please let me.

p.s: I'm aware that C - API is deprecated. However I'm maintaining an old project, so need to deal with it.

2016-02-23 05:06:18 -0600 commented answer How to change BGR to RGB of a video frame using C /C++

@zshn25 It worked thanks.

2016-02-23 05:05:55 -0600 received badge  Supporter (source)
2016-02-23 05:05:53 -0600 received badge  Scholar (source)
2016-02-23 03:51:51 -0600 received badge  Editor (source)
2016-02-23 03:50:37 -0600 commented question How to change BGR to RGB of a video frame using C /C++

@berak Then can I know how to perform the same task with C++ please? I edited the question.

2016-02-23 02:31:23 -0600 asked a question How to change BGR to RGB of a video frame using C /C++

Webcam feed reads as a inverted RGB and so the rendered colors are incorrect. I need to change BGR to RGB. Below shows incomplete code of trying to achieve the end result. Can someone guide me through this to complete? Currently using OoenCV 2.xx

GdkPixbuf* pix;
IplImage* frame;
CvCapture* capture;

frame = cvQueryFrame( capture );

// Converting BGR to RGB
for (int i = 0; i<frame->height; i++)
{
    for (int x=0; x<frame->width; x++)
    {
        // LOST
    }
}

pix = gdk_pixbuf_new_from_data((guchar*) frame->imageData,
       GDK_COLORSPACE_RGB, FALSE, frame->depth, frame->width,
       frame->height, (frame->widthStep), NULL, NULL);

Edit: Its OK the same requirement is coded in C++

2016-02-19 02:20:32 -0600 commented question Getting webcam feed with opencv to GTK+2 container.

Ok thanks a lot for the info and guidence. Above code is just for testing purpose. Main project is a bit bigger code base. So its not feasible to migrate to C++, GTK3. That would be for future phase.

2016-02-19 02:12:53 -0600 commented question Getting webcam feed with opencv to GTK+2 container.

@berak OK, Can you let me know using threads or timer how to get above code work? sorry I'm new to GTK and C programming. code pasted: http://pastebin.com/VYbwTvgP

2016-02-19 02:05:44 -0600 commented question Getting webcam feed with opencv to GTK+2 container.

@berak Thanks but I'm looking for something to correct above code.

2016-02-19 01:56:55 -0600 commented question Getting webcam feed with opencv to GTK+2 container.

@berak This was a ongoing project which hold for long time so it is gtk2 I'd need opencv to grab some frames and do edge detection. Is there any tutorial about using libv4l with gtk?

2016-02-19 01:10:07 -0600 asked a question Getting webcam feed with opencv to GTK+2 container.

I'm developing an C, GTK 2 based app. I'm about to get live webcam video display inside a gtk widget called "drawing area" However I'm new with opencv and gtk. I successfully manged to get only a single frame from webcam using opencv. Look below the working code which only grab first single frame. However not sure how to get live video frame. Could someone help?

/*
 *  compile with:
 *  gcc -o weby3 att3.c `pkg-config --libs --cflags gtk+-2.0 opencv`
 */

#include "highgui.h"
#include <gtk/gtk.h>
#include <opencv/cv.h>
#include <opencv/cxcore.h>

GdkPixbuf* pix;
IplImage* frame;
CvCapture* capture;


gboolean
expose_event_callback(GtkWidget *widget, GdkEventExpose *event, gpointer data)
{

  printf("Exposed\n");


  //while(1){
    frame = cvQueryFrame( capture );

    pix = gdk_pixbuf_new_from_data((guchar*) frame->imageData,
           GDK_COLORSPACE_RGB, FALSE, frame->depth, frame->width,
           frame->height, (frame->widthStep), NULL, NULL);


    gdk_draw_pixbuf(widget->window,
     widget->style->fg_gc[GTK_WIDGET_STATE (widget)], pix, 0, 0, 0, 0,
     -1, -1, GDK_RGB_DITHER_NONE, 0, 0); /* Other possible values are  GDK_RGB_DITHER_MAX,  GDK_RGB_DITHER_NORMAL */
  //}


    return TRUE;
}


int main( int argc, char** argv ) {
   /* GtkWidget is the storage type for widgets */
   GtkWidget *window;
   GtkWidget *drawing_area;

   gtk_init (&argc, &argv);

   capture = cvCreateCameraCapture(0);

   /* create a new window */
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title (GTK_WINDOW (window), "Hello WebCam and OpenCV!");
   g_signal_connect (G_OBJECT (window), "destroy",
    G_CALLBACK (gtk_main_quit), NULL);

   /* Sets the border width of the window. */
   gtk_container_set_border_width (GTK_CONTAINER (window), 10);

   /* Now add a child widget to the aspect frame */
   drawing_area = gtk_drawing_area_new();


   /* window since we are forcing a aspect ratio */
   gtk_widget_set_size_request(drawing_area, 600, 400);
   gtk_container_add(GTK_CONTAINER (window), drawing_area);
   gtk_widget_show(drawing_area);

   g_signal_connect (G_OBJECT (drawing_area), "expose-event",
   G_CALLBACK (expose_event_callback), NULL);

   /* and the window */
   gtk_widget_show (window);

   /* All GTK applications must have a gtk_main(). Control ends here
    * and waits for an event to occur (like a key press or
    * mouse event). */
   gtk_main ();
}