VideoFrame added methode ToPixbuf.

test16bit
Steffen Pohle 3 years ago
parent 3c39f17c45
commit b77a3d7509

@ -124,7 +124,7 @@ gboolean cb_thread_filter (gpointer data) {
pix_w = vf->w; pix_w = vf->w;
pix_h = vf->h; pix_h = vf->h;
} }
videoframe_to_pixbuf(image_pixbuf, vf); vf->ToPixbuf(image_pixbuf);
gdk_window_invalidate_rect(gtk_widget_get_window(image_da), NULL, true); gdk_window_invalidate_rect(gtk_widget_get_window(image_da), NULL, true);
filter.UnLockImageMutex(); filter.UnLockImageMutex();
@ -170,7 +170,7 @@ gboolean cb_thread_detect (gpointer data) {
pix_w = dout->image->w; pix_w = dout->image->w;
pix_h = dout->image->h; pix_h = dout->image->h;
} }
videoframe_to_pixbuf(detect_pixbuf, dout->image); dout->image->ToPixbuf(detect_pixbuf);
gdk_window_invalidate_rect(gtk_widget_get_window(detect_da), NULL, true); gdk_window_invalidate_rect(gtk_widget_get_window(detect_da), NULL, true);
filter.NewFrame(dout->image, dout->posx, dout->posy); filter.NewFrame(dout->image, dout->posx, dout->posy);

@ -111,25 +111,6 @@ gboolean videoctrl_update(gpointer data) {
} }
void videoframe_to_pixbuf(GdkPixbuf* dest, VideoFrame *src) {
int destw, desth;
unsigned char *destpixel;
if (dest == NULL || src == NULL) return;
desth = gdk_pixbuf_get_height(dest);
destw = gdk_pixbuf_get_width(dest);
destpixel = gdk_pixbuf_get_pixels(dest);
if (destw * desth < src->h * src->w) {
destw = src->w;
desth = src->h;
}
memcpy (destpixel, src->data, 3*destw*desth);
}
#define S_X(_x_) (((_x_) * clientw / pixbufw)) #define S_X(_x_) (((_x_) * clientw / pixbufw))
#define S_Y(_y_) (((_y_) * clienth / pixbufh)) #define S_Y(_y_) (((_y_) * clienth / pixbufh))
void cb_videoda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer data) { void cb_videoda_draw(GtkWidget *area, cairo_t *cr, int w, int h, gpointer data) {
@ -545,7 +526,7 @@ gboolean cb_thread_video (gpointer data) {
pix_w = vf->w; pix_w = vf->w;
pix_h = vf->h; pix_h = vf->h;
} }
videoframe_to_pixbuf(video_pixbuf, vf); vf->ToPixbuf(video_pixbuf);
detect.NewFrame(vf); detect.NewFrame(vf);
videodev->UnLockMutex(); videodev->UnLockMutex();
gdk_window_invalidate_rect(gtk_widget_get_window(video_da), NULL, true); gdk_window_invalidate_rect(gtk_widget_get_window(video_da), NULL, true);

@ -197,6 +197,10 @@ int VideoDev_Dumpfile::Grab(VideoFrame *vf) {
usleep ((inframe_nexttime-diff)*1000); usleep ((inframe_nexttime-diff)*1000);
} while (diff < inframe_nexttime); } while (diff < inframe_nexttime);
if (diff - inframe_nexttime > 1000)
printf ("%s:%d time difference to bit. (%dms) Maybe to slow hard drive?\n",
__FILE__, __LINE__, (diff - inframe_nexttime));
LockMutex(); LockMutex();
Convert(&cdata, vf, inframe, inframe_size, pixformat, w, h); Convert(&cdata, vf, inframe, inframe_size, pixformat, w, h);
UnLockMutex(); UnLockMutex();

@ -106,6 +106,29 @@ void VideoFrame::CopyTo(FloatImage *dest) {
void VideoFrame::ToPixbuf(GdkPixbuf* dest) {
int destw, desth;
unsigned char *destpixel;
if (dest == NULL) return;
desth = gdk_pixbuf_get_height(dest);
destw = gdk_pixbuf_get_width(dest);
destpixel = gdk_pixbuf_get_pixels(dest);
if (destw * desth < h * w) {
destw = w;
desth = h;
}
memcpy (destpixel, data, 3*destw*desth);
}
FloatImage::FloatImage() { FloatImage::FloatImage() {
data = NULL; data = NULL;
w = 0; w = 0;

@ -25,6 +25,7 @@ public:
class VideoFrame { class VideoFrame {
private:
public: public:
int w; int w;
int h; int h;
@ -42,6 +43,7 @@ public:
void CopyFrom(VideoFrame *source); void CopyFrom(VideoFrame *source);
void CopyFrom(FloatImage *source); void CopyFrom(FloatImage *source);
void CopyTo(FloatImage *dest); void CopyTo(FloatImage *dest);
void ToPixbuf(GdkPixbuf* dest);
}; };

Loading…
Cancel
Save