You are here

opencv frame loading without saving frame?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
Rate this item!

plugin for gimp to capture a frame from camera and to load it to gimp workspace.till nw i got the code to capture image and load the image but it is done by saving the captured frame but i want to load frame without saving the image....code till nw

#include
#include
#include
#include
#include
#include
#include

static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);

GimpPlugInInfo PLUG_IN_INFO =
{
NULL,
NULL,
query,
run
};

MAIN()

static void
query (void)
{
static GimpParamDef args[] =
{
{
GIMP_PDB_INT32,
"run-mode",
"Run mode"
},
{
GIMP_PDB_IMAGE,
"image",
"Input image"
},
{
GIMP_PDB_DRAWABLE,
"drawable",
"Input drawable"
}
};

gimp_install_procedure (
"plug-in-trail",
"trail, SHOT!",
"Displays \"trail!\" in a dialog",
"JOSEPH,ARYA,CHINJU",
"Copyright To JOSEPH",
"2013",
"_trail...",
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);

gimp_plugin_menu_register ("plug-in-trail",
"/Filters/misc");
}

static void
run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[1];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
GimpRunMode run_mode;

*nreturn_vals = 1;
*return_vals = values;

values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = status;

gint32 image_ID;
gint32 layer_ID;
run_mode = param[0].data.d_int32;
image_ID = param[1].data.d_image;
CvCapture* camera = cvCreateCameraCapture(0);

IplImage* frame = 0;

cvSetCaptureProperty(camera,CV_CAP_PROP_FRAME_WIDTH,1024) ;
cvSetCaptureProperty(camera,CV_CAP_PROP_FRAME_HEIGHT,768);

frame = cvQueryFrame(camera);

if (frame != NULL) {
printf("Frame extracted from CAM1\n\r");
cvSaveImage("/bin/test.jpg", frame,0);
} else {
printf("Null frame 1\n\r");
}
cvReleaseCapture(&camera);
cvReleaseImage(&frame);
layer_ID = gimp_file_load_layer (GIMP_RUN_NONINTERACTIVE,image_ID,"/bin/test.jpg");

gimp_image_add_layer (image_ID,layer_ID,-1);
gimp_displays_flush();
if (run_mode != GIMP_RUN_NONINTERACTIVE)
g_message("SNAPSHOT TAKEN!!");
}

GIMP Version: 
Code License: 
Subscribe to Comments for "opencv frame loading  without saving frame?"