使用缓冲区加载opencv图像而不保存?

时间:2013-04-22 09:47:47

标签: c opencv plugins layer gimp

插件让gimp从相机中捕获一个帧并将其加载到gimp workspace.till nw我得到了捕获图像并加载图像的代码但是通过保存捕获的图像完成但我想加载图像而不保存图像。

#include <libgimp/gimp.h>
#include <stdlib.h>
#include <string.h>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv/cxcore.h>
#include <stdio.h>


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",
                         "<Image>/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!!");
}

我想在不保存image.how的情况下加载图片以找到捕获图像的layer_id,或者我想知道有没有办法将图像加载到gimp而不保存捕获的图像?

0 个答案:

没有答案