Ask Your Question

venkat.330's profile - activity

2016-01-22 11:00:50 -0500 received badge  Student (source)
2015-02-21 11:03:07 -0500 commented question Memory leak in the sample code to capture image with Opencv with GLIB

@berak : I was really not aware of this sorry.. Just tried it as a option...

2015-02-21 10:59:09 -0500 asked a question Memory leak in the sample code to capture image with Opencv with GLIB

I am pretty new to camera sort of drivers and trying to explore the best available options in capturing a IMAGE from a webcam.

I indeed have specs like the APP needs to cross platform & use front cam to capture image.

To start this development process i used openCV to capture image. However, when multiple cameras are connected to the system.

To implement camera functionality here is the sample code i have built.

I see some memory leak in code when capturing continuous image with openCv. Unable to find the cause.

 Name        : cameraLibSam.c
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style

#include <stdio.h>
#include <opencv/highgui.h>
#include <glib.h>
//#include "libuvc/libuvc.h"
#include <stdio.h>
#include <windows.h>
#include <libusb-1.0/libusb.h>
#include <conio.h>

#include <opencv2/core/core_c.h>
#include <opencv2/highgui/highgui_c.h>
#include <opencv/cv.h>

#define SET 1
#define GET 0

GHashTable* cameraTable;

debug_log(char *data,int level){
typedef struct
    char cmd;
    int width;
    int height;
    int brightness;
    int contrast;
    int saturation;
    int gain;
    int quality;
    char file[20];
    char device[20];
    char nextcmd[20];
    int delay;

int process_camera (camera_dev_t *settings);

int printdev(libusb_device *dev, char *devId); //prototype of the function

 //TODO static const char version[] = VERSION;
 int run = 1;
 char temp[256];

char getCameraModel(void);

static CvCapture* capture;

void freeVals(gpointer key, gpointer value,gpointer user_data)
    printf("Key : %s --> Value : %s\n",key,value);

void printKeys(gpointer key, gpointer value,gpointer user_data)
    printf("Key : %s --> Value : %s\n",key,value);
int getcameraConfigurationInfo()
    GKeyFile *key_file;
    GError *error;
    gint keyCount;
    gsize num_keys;
    gchar **keys;
    gchar *value;

    key_file = g_key_file_new();
    error = NULL;
         g_debug("%s", error->message);
         return -1;

            keys = g_key_file_get_keys(key_file,"PROVIEW",&num_keys,&error);
            printf("dd NUMKEY %d\n",num_keys);
            int len=0;
                for(keyCount = 0;keyCount < num_keys;keyCount++)
                    if(strstr(keys[keyCount],"Priority") != NULL)
                        len = strlen(value) + 9;
                        char *charVal = (char *)malloc(len);
                        sprintf(charVal,"PROVIEW%s", value);
                        char *charKey = (char *)malloc(strlen(keys[keyCount])+9);
                        sprintf(charKey,"PROVIEW%s", keys[keyCount]);
                        g_hash_table_insert(cameraTable, charKey, charVal);
                        //if(value !=NULL)
                        if (value)
                        len = strlen(keys[keyCount]) + 9; //adding groupName ref + 1 byte extra for NULL
                        char *charKey = (char *)malloc(len);
                        char *charVal = (char *)malloc(strlen(value)+1);
                        sprintf(charKey,"PROVIEW%s", keys[keyCount]);
                        //sprintf(charVal,"PROVIEW%s", keys[keyCount]);
                        g_hash_table_insert(cameraTable, charVal, charKey);
            g_hash_table_foreach(cameraTable,(GHFunc)  printKeys,NULL);
            printf("Group not found %d\n",0);
            return -1;
    return 0;

int printdev(libusb_device *dev,char *devId) {
    int i = 0;
    struct libusb_device_descriptor desc;
    int r = libusb_get_device_descriptor(dev, &desc);
    if (r < 0) {
        printf("failed to get device descriptor\n");
        return -2;
    if((int)desc.bDeviceClass== 239){
        printf("Number ...
2015-02-14 23:54:46 -0500 asked a question accessing a particular connected camera by its VID : PID

hi I am pretty new opencv and currently exploring documents and samples.

With that i am trying to check for option like openign camera based on VID / PID. This option would help me in opening a specific camera the system