gimp 的插件,用于从相机捕获帧并将其加载到 gimp 工作区。直到 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!!");
}
我想在不保存图像的情况下加载图像。如何找到捕获图像的 layer_id 或者我想知道是否有任何方法可以在不保存捕获图像的情况下将图像加载到 gimp?