compositor f1-f10/j/p shortcuts, opencv upgrade, new stylize,puzzle opencv plugins
authorGood Guy <good1.2guy@gmail.com>
Tue, 3 Apr 2018 00:56:01 +0000 (18:56 -0600)
committerGood Guy <good1.2guy@gmail.com>
Tue, 3 Apr 2018 00:56:01 +0000 (18:56 -0600)
25 files changed:
cinelerra-5.1/cinelerra/cwindowgui.C
cinelerra-5.1/cinelerra/cwindowtool.C
cinelerra-5.1/cinelerra/editpanel.C
cinelerra-5.1/cinelerra/editpanel.h
cinelerra-5.1/cinelerra/mwindowgui.C
cinelerra-5.1/cinelerra/setformat.C
cinelerra-5.1/cinelerra/setformat.h
cinelerra-5.1/guicast/bcwindowbase.C
cinelerra-5.1/guicast/bcwindowbase.h
cinelerra-5.1/guicast/keys.h
cinelerra-5.1/opencv_build
cinelerra-5.1/plugin_defs
cinelerra-5.1/plugins/Makefile
cinelerra-5.1/plugins/flowobj/flowobj.C
cinelerra-5.1/plugins/moveobj/moveobj.C
cinelerra-5.1/plugins/puzzleobj/Makefile [new file with mode: 0644]
cinelerra-5.1/plugins/puzzleobj/puzzleobj.C [new file with mode: 0644]
cinelerra-5.1/plugins/puzzleobj/puzzleobj.h [new file with mode: 0644]
cinelerra-5.1/plugins/puzzleobj/puzzleobjwindow.C [new file with mode: 0644]
cinelerra-5.1/plugins/puzzleobj/puzzleobjwindow.h [new file with mode: 0644]
cinelerra-5.1/plugins/stylizeobj/Makefile [new file with mode: 0644]
cinelerra-5.1/plugins/stylizeobj/stylizeobj.C [new file with mode: 0644]
cinelerra-5.1/plugins/stylizeobj/stylizeobj.h [new file with mode: 0644]
cinelerra-5.1/plugins/stylizeobj/stylizeobjwindow.C [new file with mode: 0644]
cinelerra-5.1/plugins/stylizeobj/stylizeobjwindow.h [new file with mode: 0644]

index 37dd35bf20c3c244aead401cf5705b10e811dac6..d7bcf789f5fc79595be3dc7ce376679f9217e0a1 100644 (file)
@@ -219,14 +219,7 @@ void CWindowGUI::create_objects()
        tool_panel = new CWindowTool(mwindow, this);
        tool_panel->Thread::start();
 
-
        set_operation(mwindow->edl->session->cwindow_operation);
-
-
-
-       canvas->draw_refresh(0);
-
-
        draw_status(0);
        unlock_window();
 }
@@ -425,15 +418,26 @@ void CWindowGUI::zoom_canvas(double value, int update_menu)
        canvas->draw_refresh();
 }
 
-
-
 void CWindowGUI::set_operation(int value)
 {
-       mwindow->edl->session->cwindow_operation = value;
+       switch( value ) {
+       case CWINDOW_TOOL_WINDOW:
+               mwindow->edl->session->tool_window = !mwindow->edl->session->tool_window;
+               composite_panel->operation[CWINDOW_TOOL_WINDOW]->update(mwindow->edl->session->tool_window);
+               tool_panel->update_show_window();
+               return;
+       case CWINDOW_TITLESAFE:
+               mwindow->edl->session->safe_regions = !mwindow->edl->session->safe_regions;
+               composite_panel->operation[CWINDOW_TITLESAFE]->update(mwindow->edl->session->safe_regions);
+               value = mwindow->edl->session->cwindow_operation;
+               break;
+       default:
+               mwindow->edl->session->cwindow_operation = value;
+               composite_panel->set_operation(value);
+               break;
+       }
 
-       composite_panel->set_operation(value);
        edit_panel->update();
-
        tool_panel->start_tool(value);
        canvas->draw_refresh();
 }
@@ -453,6 +457,7 @@ int CWindowGUI::close_event()
 int CWindowGUI::keypress_event()
 {
        int result = 0;
+       int cwindow_operation = CWINDOW_NONE;
 
        switch(get_keypress())
        {
@@ -556,6 +561,21 @@ int CWindowGUI::keypress_event()
                        }
                        break;
 
+               case KEY_F1:    cwindow_operation = CWINDOW_PROTECT;    break;
+               case KEY_F2:    cwindow_operation = CWINDOW_ZOOM;       break;
+               case KEY_F3:    cwindow_operation = CWINDOW_MASK;       break;
+               case KEY_F4:    cwindow_operation = CWINDOW_RULER;      break;
+               case KEY_F5:    cwindow_operation = CWINDOW_CAMERA;     break;
+               case KEY_F6:    cwindow_operation = CWINDOW_PROJECTOR;  break;
+               case KEY_F7:    cwindow_operation = CWINDOW_CROP;       break;
+               case KEY_F8:    cwindow_operation = CWINDOW_EYEDROP;    break;
+               case KEY_F9:    cwindow_operation = CWINDOW_TOOL_WINDOW; break;
+               case KEY_F10:   cwindow_operation = CWINDOW_TITLESAFE;  break;
+       }
+
+       if( cwindow_operation >= 0 ) {
+               set_operation(cwindow_operation);
+               result = 1;
        }
 
        if(!result) result = transport->keypress_event();
index f3fda9a4a85b47564b9de9c09028549fbaa611f0..cb3a1d7e4f7cf4d0187a8ce82e631d34d6702451 100644 (file)
@@ -289,9 +289,28 @@ int CWindowToolGUI::close_event()
 
 int CWindowToolGUI::keypress_event()
 {
-       if(get_keypress() == 'w' || get_keypress() == 'W')
+       int result = 0;
+       int cwindow_operation = CWINDOW_NONE;
+
+       switch( get_keypress() ) {
+       case 'w':
+       case 'W':
                return close_event();
-       return 0;
+       case KEY_F1:
+       case KEY_F2:
+       case KEY_F3:
+       case KEY_F4:
+       case KEY_F5:
+       case KEY_F6:
+       case KEY_F7:
+       case KEY_F8:
+       case KEY_F9:
+       case KEY_F10:
+               resend_event(thread->gui);
+               result = 1;
+       }
+
+       return result;
 }
 
 int CWindowToolGUI::translation_event()
index 75ee8d4288d67f6cc1cbd50f57938ff59ecf7026..32b2e848481e5dcd8a1e13081660df9b1e5a1f2a 100644 (file)
@@ -979,7 +979,7 @@ EditClick2Play::EditClick2Play(MWindow *mwindow, EditPanel *panel, int x, int y)
 {
         this->mwindow = mwindow;
         this->panel = panel;
-        set_tooltip(_("Click to play"));
+        set_tooltip(_("Click to play (p)"));
 }
 int EditClick2Play::handle_event()
 {
@@ -990,6 +990,21 @@ int EditClick2Play::handle_event()
                mwindow->edl->session->vwindow_click2play = value;
        return 1;
 }
+int EditClick2Play::keypress_event()
+{
+       int key = get_keypress();
+       if( key == 'p' && !ctrl_down() && !shift_down() && !alt_down() ) {
+               int value = get_value() ? 0 : 1;
+               update(value);
+               if( !panel->is_vwindow() )
+                       mwindow->edl->session->cwindow_click2play = value;
+               else
+                       mwindow->edl->session->vwindow_click2play = value;
+               return 1;
+       }
+       return 0;
+}
+
 
 EditCommercial::EditCommercial(MWindow *mwindow, EditPanel *panel, int x, int y)
  : BC_Button(x, y, mwindow->theme->get_image_set("commercial"))
@@ -1353,7 +1368,7 @@ KeyFrameButton::KeyFrameButton(MWindow *mwindow, EditPanel *panel, int x, int y)
 {
        this->mwindow = mwindow;
        this->panel = panel;
-       set_tooltip(_("Generate keyframes while tweeking"));
+       set_tooltip(_("Generate keyframes while tweeking (j)"));
 }
 
 int KeyFrameButton::handle_event()
@@ -1363,6 +1378,18 @@ int KeyFrameButton::handle_event()
        return 1;
 }
 
+int KeyFrameButton::keypress_event()
+{
+       int key = get_keypress();
+       if( key == 'j' && !ctrl_down() && !shift_down() && !alt_down() ) {
+               int value = get_value() ? 0 : 1;
+               update(value);
+               mwindow->set_auto_keyframes(value,
+                       !panel->is_mwindow(), panel->is_mwindow());
+               return 1;
+       }
+       return 0;
+}
 
 LockLabelsButton::LockLabelsButton(MWindow *mwindow, int x, int y)
  : BC_Toggle(x, y,
index 47b703bef89670087d9fd7b0ae6161ade642064c..67ce8a1e67e98cf68831cd5613f7e75249b1fef7 100644 (file)
@@ -173,6 +173,7 @@ public:
         EditClick2Play();
 
         int handle_event();
+       int keypress_event();
 
        MWindow *mwindow;
        EditPanel *panel;
@@ -380,6 +381,7 @@ class KeyFrameButton : public BC_Toggle
 public:
        KeyFrameButton(MWindow *mwindow, EditPanel *panel, int x, int y);
        int handle_event();
+       int keypress_event();
        MWindow *mwindow;
        EditPanel *panel;
 };
index d1aea0fc026c6c0440f12b839ce345bc74e5e654..f7cd97cd94accae12af1451d1c5a0b7df7d21714 100644 (file)
@@ -1039,7 +1039,7 @@ int MWindowGUI::drag_stop()
        }
 
 
-//printf("TrackCanvas::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
+//printf("MWindowGUI::drag_stop %d %d\n", redraw, mwindow->session->current_operation);
        if(redraw)
        {
                mwindow->edl->tracks->update_y_pixels(mwindow->theme);
@@ -1162,6 +1162,8 @@ int MWindowGUI::keypress_event()
        int result = mbuttons->keypress_event();
        if( result ) return result;
 
+       Track *this_track = 0;
+
        switch(get_keypress()) {
        case 'e':
                mwindow->toggle_editing_mode();
@@ -1263,7 +1265,6 @@ int MWindowGUI::keypress_event()
 
        case TAB:
        case LEFTTAB:
-               Track *this_track = 0;
                for( int i=0; i<TOTAL_PANES; ++i ) {
                        if( !pane[i] ) continue;
                        if( (this_track = pane[i]->over_track()) != 0 ) break;
@@ -1287,10 +1288,23 @@ int MWindowGUI::keypress_event()
                update(0, 1, 0, 0, 1, 0, 1);
                unlock_window();
                mwindow->cwindow->update(0, 1, 1);
-               lock_window("TrackCanvas::keypress_event 3");
+               lock_window("MWindowGUI::keypress_event 3");
 
                result = 1;
                break;
+
+       case KEY_F1:
+       case KEY_F2:
+       case KEY_F3:
+       case KEY_F4:
+       case KEY_F5:
+       case KEY_F6:
+       case KEY_F7:
+       case KEY_F8:
+       case KEY_F9:
+       case KEY_F10:
+               resend_event(mwindow->cwindow->gui);
+               return 1;
        }
 
 // since things under cursor have changed...
index b70f68824cf1bb8c172dcec863fe9bc35d610ccc..bf22103f2c0e6e7889bc5e3b63b5552af991ea3e 100644 (file)
@@ -279,22 +279,18 @@ void SetFormatThread::update_aspect()
 
 
 SetFormatWindow::SetFormatWindow(MWindow *mwindow,
-       SetFormatThread *thread,
-       int x,
-       int y)
- : BC_Window(_(PROGRAM_NAME ": Set Format"),
-       x,
-       y,
-       mwindow->theme->setformat_w,
-       mwindow->theme->setformat_h,
-       -1,
-       -1,
-       0,
-       0,
-       1)
+       SetFormatThread *thread, int x, int y)
+ : BC_Window(_(PROGRAM_NAME ": Set Format"), x, y,
+       mwindow->theme->setformat_w, mwindow->theme->setformat_h,
+       -1, -1, 0, 0, 1)
 {
        this->mwindow = mwindow;
        this->thread = thread;
+       presets = 0;
+}
+SetFormatWindow::~SetFormatWindow()
+{
+       delete presets;
 }
 
 void SetFormatWindow::create_objects()
index 89ede118e40f62291e0f73ff5c7283d0b79f9b79..b85fce1752aa3e7f7a2346913daebfdecaca9f86 100644 (file)
@@ -202,11 +202,8 @@ public:
 class FormatSwapExtents : public BC_Button
 {
 public:
-       FormatSwapExtents(MWindow *mwindow,
-               SetFormatThread *thread,
-               SetFormatWindow *gui,
-               int x,
-               int y);
+       FormatSwapExtents(MWindow *mwindow, SetFormatThread *thread,
+               SetFormatWindow *gui, int x, int y);
        int handle_event();
        MWindow *mwindow;
        SetFormatThread *thread;
@@ -217,9 +214,8 @@ class SetFormatWindow : public BC_Window
 {
 public:
        SetFormatWindow(MWindow *mwindow,
-               SetFormatThread *thread,
-               int x,
-               int y);
+               SetFormatThread *thread, int x, int y);
+       ~SetFormatWindow();
 
        void create_objects();
        const char* get_preset_text();
index f9eb98f20b18ee5d22609326afcc0382f7283125..5b1331061d321bfb3dec45a55a8bacef288ff9fd 100644 (file)
@@ -255,6 +255,7 @@ int BC_WindowBase::initialize()
        keys_return[0] = 0;
        is_deleting = 0;
        window_lock = 0;
+       resend_event_window = 0;
        x = 0;
        y = 0;
        w = 0;
@@ -1254,6 +1255,18 @@ locking_message = event->xclient.message_type;
                case XK_KP_Insert:      key_pressed = KPINS;    break;
                case XK_KP_Decimal:
                case XK_KP_Delete:      key_pressed = KPDEL;    break;
+
+               case XK_F1:             key_pressed = KEY_F1;   break;
+               case XK_F2:             key_pressed = KEY_F2;   break;
+               case XK_F3:             key_pressed = KEY_F3;   break;
+               case XK_F4:             key_pressed = KEY_F4;   break;
+               case XK_F5:             key_pressed = KEY_F5;   break;
+               case XK_F6:             key_pressed = KEY_F6;   break;
+               case XK_F7:             key_pressed = KEY_F7;   break;
+               case XK_F8:             key_pressed = KEY_F8;   break;
+               case XK_F9:             key_pressed = KEY_F9;   break;
+               case XK_F10:            key_pressed = KEY_F10;  break;
+
                case XK_Menu:           key_pressed = KPMENU;   break;  /* menu */
 // remote control
 // above       case XK_KP_Enter:       key_pressed = KPENTER;  break;  /* check */
@@ -1351,7 +1364,14 @@ locking_message = event->xclient.message_type;
 
 #ifndef SINGLE_THREAD
        unlock_window();
-       if(event) delete event;
+       if(event) {
+               if( resend_event_window ) {
+                       resend_event_window->put_event(event);
+                       resend_event_window = 0;
+               }
+               else
+                       delete event;
+       }
 #else
 //     if(done) completion_lock->unlock();
 #endif
@@ -4473,6 +4493,20 @@ void BC_WindowBase::dequeue_events(Window win)
        event_lock->unlock();
 }
 
+int BC_WindowBase::resend_event(BC_WindowBase *window)
+{
+       if( resend_event_window ) return 1;
+       resend_event_window = window;
+       return 0;
+}
+
+#else
+
+int BC_WindowBase::resend_event(BC_WindowBase *window)
+{
+       return 1;
+}
+
 #endif // SINGLE_THREAD
 
 int BC_WindowBase::get_id()
index 82e6d57cea0516b210b822b13c62d56e809c3206..5d17e5ee3064362c2cc23e73d3b11c91b1f2e1ad 100644 (file)
@@ -224,7 +224,6 @@ public:
        int get_deleting();
 
 
-
 //============================= OpenGL functions ===============================
 // OpenGL functions must be called from inside a BC_Synchronous command.
 // Create openGL context and bind it to the current window.
@@ -269,6 +268,7 @@ public:
        virtual int keyboard_listener(BC_WindowBase *wp) { return 0; }
        void add_keyboard_listener(int(BC_WindowBase::*handler)(BC_WindowBase *));
        void del_keyboard_listener(int(BC_WindowBase::*handler)(BC_WindowBase *));
+       int resend_event(BC_WindowBase *window);
 // Dimensions
        virtual int get_w() { return w; }
        virtual int get_h() { return h; }
@@ -658,6 +658,8 @@ private:
        BC_PopupMenu* active_popup_menu;
 // pointer to the active subwindow
        BC_WindowBase* active_subwindow;
+// pointer to the window to which to put the current event
+       BC_WindowBase* resend_event_window;
 // thread id of display locker
        pthread_t display_lock_owner;
 
index d15c12414a7520ff6973bfd046540b6b74393944..c48ee590f066650365de6f2997a29885e5d16daf 100644 (file)
@@ -34,7 +34,6 @@
 #define BACKSPACE           262
 #define ESC                 263
 #define TAB                 264
-
 // Number pad keys
 #define KPPLUS              265
 #define KPMINUS             266
 #define KPRECD              297
 #define KPSTOP              298
 #define KPAUSE              299
+// function keys
+#define KEY_F1              301
+#define KEY_F2              302
+#define KEY_F3              303
+#define KEY_F4              304
+#define KEY_F5              305
+#define KEY_F6              306
+#define KEY_F7              307
+#define KEY_F8              308
+#define KEY_F9              309
+#define KEY_F10             310
 
 #define RETURN              13
 #define NEWLINE             13
index 86d96d1c6fda21767d8c7d771574c9bc88613655..097e97f5a41a7379a90504f75f86bc748ca7454a 100644 (file)
@@ -80,8 +80,8 @@ $(opencv)/build: $(opencv).src
   -DOPENCV_EXTRA_MODULES_PATH="$(opencv)_contrib/modules/"
 
 LFLAGS += -Wl,--start-group
-LFLAGS += $(shell ls -1 $(opencv_prefix)/lib/libopencv_*.a 2> /dev/null)
-LFLAGS += $(shell ls -1 $(opencv_prefix)/share/OpenCV/3rdparty/lib/lib*.a 2> /dev/null)
+LFLAGS += $(shell ls -1 $(opencv_prefix)/lib*/libopencv_*.a 2> /dev/null)
+LFLAGS += $(shell ls -1 $(opencv_prefix)/share/OpenCV/3rdparty/lib*/lib*.a 2> /dev/null)
 LFLAGS += -Wl,--end-group
 else ifeq ($(bld),dyn)
 $(opencv)/build: $(opencv).src
index ecf3dc9bff9017a645b448f6b1700a9117ec567d..8f6e6c4cc7e3b5188f1a6f801eff3210f24adccf 100644 (file)
@@ -23,7 +23,8 @@ colors := brightness bluebanana C41 color3way colorbalance huesaturation \
        gamma gradient histeq histogram histogram_bezier threshold
 
 plugin_dirs += exotic
-exotic := aging burn dot holo oil edge spherecam
+exotic := aging burn dot holo oil edge spherecam \
+        findobj flowobj gaborobj moveobj stylizeobj puzzleobj
 
 plugin_dirs += audio_tools
 audio_tools := audioscope cdripper compressor dcoffset delayaudio \
@@ -40,7 +41,7 @@ video_tools := blur decimate delayvideo denoisemjpeg denoisevideo downsample \
        motion2 motionblur motion motion-cv motion-hv motion51 \
        overlay radialblur reframe reframert reroute reversevideo \
        rumbler seltempavg sharpen svg titler timeavg timefront \
-       unsharp videoscope wave zoomblur findobject descratch
+       unsharp videoscope wave zoomblur descratch
 
 plugin_dirs += blending
 blending := crikey chromakeyhsv chromakey diffkey
index e86526abb7f3501f4a55536d652d5ca4e86714e3..bd7d85910e4f4a305a1070d0268b62121c0c1f95 100644 (file)
@@ -8,7 +8,7 @@ endif
 ifneq ($(WANT_OPENCV), no)
 want_var:=$(WANT_OPENCV)
 include $(TOPDIR)/opencv_build
-OPENCV_OBJS := findobj flowobj gaborobj moveobj
+OPENCV_OBJS := findobj flowobj gaborobj moveobj stylizeobj puzzleobj
 $(OPENCV_OBJS): opencv
 endif
 
index 9ebeb4f9d22d19edce6e4ff83f4ef19a04d8b9d8..1f991e6cbef3528a246ffcb87ef0a263bde18b6d 100644 (file)
@@ -272,7 +272,7 @@ int FlowObj::process_buffer(VFrame *frame, int64_t start_position, double frame_
        goodFeaturesToTrack(next_mat,
                *next_corners, corner_count, 0.01,        // quality_level
                min_distance, noArray(), block_size,
-               0,           // use_harris
+               false,       // use_harris
                0.04);       // k
 
        if( !next_mat.empty() && next_corners->size() > 3 ) {
index 4f5fd0fd36dcf0b6fad250308a466606cd251e6c..e64575552c1974989b34608d61f4eee62e3902e3 100644 (file)
@@ -255,7 +255,7 @@ int MoveObj::process_buffer(VFrame *frame, int64_t start_position, double frame_
        goodFeaturesToTrack(next_mat,
                *next_corners, corner_count, 0.01,        // quality_level
                min_distance, noArray(), block_size,
-               0,           // use_harris
+               false,       // use_harris
                0.04);       // k
 
        ptV pt1, pt2;
diff --git a/cinelerra-5.1/plugins/puzzleobj/Makefile b/cinelerra-5.1/plugins/puzzleobj/Makefile
new file mode 100644 (file)
index 0000000..65484d9
--- /dev/null
@@ -0,0 +1,21 @@
+default: all
+
+TOPDIR?=../..
+include $(TOPDIR)/plugin_defs
+
+PLUGIN = puzzleobj
+
+OBJS := \
+       $(OBJDIR)/puzzleobj.o \
+       $(OBJDIR)/puzzleobjwindow.o \
+
+want_var:=$(WANT_OPENCV)
+include $(TOPDIR)/opencv_build
+include $(TOPDIR)/plugin_config
+
+all:   opencv
+       +make $(OUTPUT)
+
+$(OBJDIR)/puzzleobj.o: puzzleobj.C puzzleobj.h puzzleobjwindow.h
+$(OBJDIR)/puzzleobjwindow.o: puzzleobjwindow.C puzzleobj.h puzzleobjwindow.h
+
diff --git a/cinelerra-5.1/plugins/puzzleobj/puzzleobj.C b/cinelerra-5.1/plugins/puzzleobj/puzzleobj.C
new file mode 100644 (file)
index 0000000..6861bec
--- /dev/null
@@ -0,0 +1,222 @@
+/*
+ * CINELERRA
+ * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * 
+ */
+
+#include "clip.h"
+#include "filexml.h"
+#include "puzzleobj.h"
+#include "puzzleobjwindow.h"
+#include "language.h"
+#include "mutex.h"
+
+REGISTER_PLUGIN(PuzzleObj)
+
+
+PuzzleObjConfig::PuzzleObjConfig()
+{
+       pixels = 400;
+       iterations = 10;
+}
+
+int PuzzleObjConfig::equivalent(PuzzleObjConfig &that)
+{
+       return 1;
+}
+
+void PuzzleObjConfig::copy_from(PuzzleObjConfig &that)
+{
+}
+
+void PuzzleObjConfig::interpolate( PuzzleObjConfig &prev, PuzzleObjConfig &next, 
+       long prev_frame, long next_frame, long current_frame)
+{
+       copy_from(next);
+}
+
+void PuzzleObjConfig::limits()
+{
+}
+
+
+PuzzleObj::PuzzleObj(PluginServer *server)
+ : PluginVClient(server)
+{
+       ss_width = 0;  ss_height = 0;  ss_channels = 0;
+       ss_pixels = 0; ss_levels = 0;  ss_prior = 0;
+       ss_hist_bins = 0;
+}
+
+PuzzleObj::~PuzzleObj()
+{
+}
+
+const char* PuzzleObj::plugin_title() { return N_("PuzzleObj"); }
+int PuzzleObj::is_realtime() { return 1; }
+
+NEW_WINDOW_MACRO(PuzzleObj, PuzzleObjWindow);
+LOAD_CONFIGURATION_MACRO(PuzzleObj, PuzzleObjConfig)
+
+void PuzzleObj::save_data(KeyFrame *keyframe)
+{
+       FileXML output;
+
+// cause data to be stored directly in text
+       output.set_shared_output(keyframe->get_data(), MESSAGESIZE);
+       output.tag.set_title("PUZZLEOBJ");
+       output.tag.set_property("PIXELS", config.pixels);
+       output.tag.set_property("ITERATIONS", config.iterations);
+       output.append_tag();
+       output.append_newline();
+       output.tag.set_title("/PUZZLEOBJ");
+       output.append_tag();
+       output.append_newline();
+       output.terminate_string();
+}
+
+void PuzzleObj::read_data(KeyFrame *keyframe)
+{
+       FileXML input;
+       input.set_shared_input(keyframe->get_data(), strlen(keyframe->get_data()));
+
+       int result = 0;
+       while( !(result = input.read_tag()) ) {
+               if( input.tag.title_is("PUZZLEOBJ") ) {
+                       config.pixels     = input.tag.get_property("PIXELS", config.pixels);
+                       config.iterations = input.tag.get_property("ITERATIONS", config.iterations);
+                       config.limits();
+               }
+               else if( input.tag.title_is("/PUZZLEOBJ") )
+                       result = 1;
+       }
+}
+
+void PuzzleObj::update_gui()
+{
+       if( !thread ) return;
+       if( !load_configuration() ) return;
+       thread->window->lock_window("PuzzleObj::update_gui");
+       PuzzleObjWindow *window = (PuzzleObjWindow*)thread->window;
+       window->unlock_window();
+}
+
+void PuzzleObj::to_mat(Mat &mat, int mcols, int mrows,
+       VFrame *inp, int ix,int iy, int mcolor_model)
+{
+       int mcomp = BC_CModels::components(mcolor_model);
+       int mbpp = BC_CModels::calculate_pixelsize(mcolor_model);
+       int psz = mbpp / mcomp;
+       int mdepth = psz < 2 ? CV_8U : psz < 4 ? CV_16U : CV_32F;
+       if( mat.dims != 2 || mat.depth() != mdepth || mat.channels() != mcomp ||
+           mat.cols != mcols || mat.rows != mrows ) {
+               mat.release();
+       }
+       if( mat.empty() ) {
+               int type = CV_MAKETYPE(mdepth, mcomp);
+               mat.create(mrows, mcols, type);
+       }
+       uint8_t *mat_rows[mrows];
+       for( int y=0; y<mrows; ++y ) mat_rows[y] = mat.ptr(y);
+       uint8_t **inp_rows = inp->get_rows();
+       int ibpl = inp->get_bytes_per_line(), mbpl = mcols * mbpp;
+       int icolor_model = inp->get_color_model();
+       BC_CModels::transfer(mat_rows, mcolor_model, 0,0, mcols,mrows, mbpl,
+               inp_rows, icolor_model, ix,iy, mcols,mrows, ibpl, 0);
+//     VFrame vfrm(mat_rows[0], -1, mcols,mrows, mcolor_model, mat_rows[1]-mat_rows[0]);
+//     static int vfrm_no = 0; char vfn[64]; sprintf(vfn,"/tmp/idat/%06d.png", vfrm_no++);
+//     vfrm.write_png(vfn);
+}
+
+int PuzzleObj::process_buffer(VFrame *frame, int64_t start_position, double frame_rate)
+{
+
+       //int need_reconfigure =
+       load_configuration();
+       input = get_input(0);
+       output = get_output(0);
+       width = input->get_w();
+       height = input->get_h();
+       color_model = input->get_color_model();
+       VFrame *iframe = input;
+       read_frame(iframe, 0, start_position, frame_rate, 0);
+       int cv_color_model = BC_RGB888;
+       if( color_model != cv_color_model ) {
+               iframe = new_temp(width,height, cv_color_model);
+               iframe->transfer_from(input);
+       }
+       int prior = 2;
+       int levels = 4;
+       int hist_bins = 5;
+       int channels = BC_CModels::components(cv_color_model);
+
+// load next image
+       to_mat(next_img, width,height, iframe, 0,0, cv_color_model);
+       Mat img; //, img1;
+       cvtColor(next_img, img, COLOR_RGB2HSV);
+       if( !sseeds.empty() &&
+           ( ss_width != width || ss_height != height || ss_channels != channels ||
+           ss_pixels != config.pixels || ss_levels != levels || ss_prior != prior ||
+           ss_hist_bins != hist_bins ) )
+               sseeds.release();
+       if( sseeds.empty() )
+               sseeds = ximgproc::createSuperpixelSEEDS(
+                       ss_width=width, ss_height=height, ss_channels=channels,
+                       ss_pixels=config.pixels, ss_levels=levels, ss_prior=prior,
+                       ss_hist_bins=hist_bins, false);
+       sseeds->iterate(img, config.iterations);
+//     sseeds->getLabels(img1);
+       sseeds->getLabelContourMask(img, false);
+       uint8_t **irows = input->get_rows();
+       int ibpp = BC_CModels::calculate_pixelsize(color_model);
+       uint8_t **orows = output->get_rows();
+       int obpp = BC_CModels::calculate_pixelsize(color_model);
+       if( BC_CModels::is_float(color_model) ) {
+               for( int y=0; y<height; ++y ) {
+                       uint8_t *rp = img.ptr(y);
+                       float *ip = (float*)irows[y], *op = (float*)orows[y];
+                       for( int x=0; x<width; ++x,++rp ) {
+                               if( *rp ) { op[0] = 1.0f; op[1] = 1.0f; op[2] = 1.0f; }
+                               else { op[0] = ip[0];  op[1] = ip[1];  op[2] = ip[2]; }
+                               ip = (float*)((char*)ip + ibpp);
+                               op = (float*)((char*)op + obpp);
+                       }
+               }
+       }
+       else if( BC_CModels::is_yuv(color_model) ) {
+               for( int y=0; y<height; ++y ) {
+                       uint8_t *rp = img.ptr(y), *ip = irows[y], *op = orows[y];
+                       for( int x=0; x<width; ++x,++rp ) {
+                               if( *rp ) { op[0] = 0xff; op[1] = 0x80; op[2] = 0x80; }
+                               else { op[0] = ip[0];  op[1] = ip[1];  op[2] = ip[2]; }
+                               ip += ibpp;  op += obpp;
+                       }
+               }
+       }
+       else {
+               for( int y=0; y<height; ++y ) {
+                       uint8_t *rp = img.ptr(y), *ip = irows[y], *op = orows[y];
+                       for( int x=0; x<width; ++x,++rp ) {
+                               if( *rp ) { op[0] = 0xff; op[1] = 0xff; op[2] = 0xff; }
+                               else { op[0] = ip[0];  op[1] = ip[1];  op[2] = ip[2]; }
+                               ip += ibpp;  op += obpp;
+                       }
+               }
+       }
+       return 0;
+}
+
diff --git a/cinelerra-5.1/plugins/puzzleobj/puzzleobj.h b/cinelerra-5.1/plugins/puzzleobj/puzzleobj.h
new file mode 100644 (file)
index 0000000..197522f
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * CINELERRA
+ * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef PUZZLEOBJ_H
+#define PUZZLEOBJ_H
+
+#include "pluginvclient.h"
+#include "loadbalance.h"
+#include "mutex.inc"
+
+#include "opencv2/core/types.hpp"
+#include "opencv2/core/mat.hpp"
+#include "opencv2/calib3d.hpp"
+#include "opencv2/photo.hpp"
+#include "opencv2/ximgproc.hpp"
+#include "opencv2/video/video.hpp"
+
+#include <vector>
+
+
+using namespace std;
+using namespace cv;
+using namespace cv::ximgproc;
+
+class PuzzleObjConfig;
+class PuzzleObj;
+
+
+class PuzzleObjConfig
+{
+public:
+       PuzzleObjConfig();
+       int pixels;
+       int iterations;
+
+       int equivalent(PuzzleObjConfig &that);
+       void copy_from(PuzzleObjConfig &that);
+       void interpolate(PuzzleObjConfig &prev, PuzzleObjConfig &next, 
+               long prev_frame, long next_frame, long current_frame);
+       void limits();
+};
+
+class PuzzleObj : public PluginVClient
+{
+public:
+       PuzzleObj(PluginServer *server);
+       ~PuzzleObj();
+       PLUGIN_CLASS_MEMBERS2(PuzzleObjConfig)
+       int is_realtime();
+       void update_gui();
+       void save_data(KeyFrame *keyframe);
+       void read_data(KeyFrame *keyframe);
+       int process_buffer(VFrame *frame, int64_t start_position, double frame_rate);
+       void to_mat(Mat &mat, int mcols, int mrows,
+               VFrame *inp, int ix,int iy, int mcolor_model);
+
+       int width, height, color_model;
+       VFrame *input, *output;
+
+       int ss_width, ss_height, ss_channels;
+       int ss_pixels, ss_levels, ss_prior, ss_hist_bins;
+
+       Ptr<SuperpixelSEEDS> sseeds;
+       Mat next_img;
+};
+
+#endif
diff --git a/cinelerra-5.1/plugins/puzzleobj/puzzleobjwindow.C b/cinelerra-5.1/plugins/puzzleobj/puzzleobjwindow.C
new file mode 100644 (file)
index 0000000..da3d147
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * CINELERRA
+ * Copyright (C) 2014 Adam Williams <broadcast at earthling dot net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * 
+ */
+
+#include "bcdisplayinfo.h"
+#include "clip.h"
+#include "language.h"
+#include "puzzleobj.h"
+#include "puzzleobjwindow.h"
+#include "theme.h"
+
+PuzzleObjWindow::PuzzleObjWindow(PuzzleObj *plugin)
+ : PluginClientWindow(plugin, 320, 100, 320, 100, 0)
+{
+       this->plugin = plugin; 
+       pixels = 0;
+       iterations = 0;
+       pixels_title = 0;
+       iterations_title = 0;
+}
+
+PuzzleObjWindow::~PuzzleObjWindow()
+{
+}
+
+void PuzzleObjWindow::create_objects()
+{
+       int x = 10, y = 10;
+       BC_Title *title = new BC_Title(x, y, _("PuzzleObj"));
+       add_subwindow(title);
+       y += title->get_h() + 10;
+       int x1 = x + 80;
+       add_subwindow(pixels_title = new BC_Title(x,y,_("Pixels:")));
+       add_subwindow(pixels = new PuzzleObjISlider(this,
+                       x1,y,180, 1,1000, &plugin->config.pixels));
+       y += pixels->get_h() + 10;
+       add_subwindow(iterations_title = new BC_Title(x,y,_("Iterations:")));
+       add_subwindow(iterations = new PuzzleObjISlider(this,
+                       x1,y,180, 0,50, &plugin->config.iterations));
+       show_window(1);
+}
+
+PuzzleObjISlider::PuzzleObjISlider(PuzzleObjWindow *win,
+               int x, int y, int w, int min, int max, int *output)
+ : BC_ISlider(x, y, 0,w,w, min,max, *output)
+{
+        this->win = win;
+        this->output = output;
+}
+PuzzleObjISlider::~PuzzleObjISlider()
+{
+}
+
+int PuzzleObjISlider::handle_event()
+{
+       *output = get_value();
+       win->plugin->send_configure_change();
+        return 1;
+}
+
diff --git a/cinelerra-5.1/plugins/puzzleobj/puzzleobjwindow.h b/cinelerra-5.1/plugins/puzzleobj/puzzleobjwindow.h
new file mode 100644 (file)
index 0000000..d71cdc8
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * CINELERRA
+ * Copyright (C) 2008-2014 Adam Williams <broadcast at earthling dot net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * 
+ */
+
+#ifndef PUZZLEOBJWINDOW_H
+#define PUZZLEOBJWINDOW_H
+
+
+#include "guicast.h"
+
+class PuzzleObj;
+class PuzzleObjWindow;
+class PuzzleObjISlider;
+
+class PuzzleObjISlider : public BC_ISlider
+{
+public:
+       PuzzleObjISlider(PuzzleObjWindow *win,
+               int x, int y, int w, int min, int max, int *output);
+       ~PuzzleObjISlider();
+       int handle_event();
+
+       PuzzleObjWindow *win;
+       int *output;
+};
+
+class PuzzleObjWindow : public PluginClientWindow
+{
+public:
+       PuzzleObjWindow(PuzzleObj *plugin);
+       ~PuzzleObjWindow();
+
+       void create_objects();
+
+       PuzzleObj *plugin;
+       BC_Title *pixels_title;
+       BC_Title *iterations_title;
+       PuzzleObjISlider *pixels;
+       PuzzleObjISlider *iterations;
+};
+
+#endif
diff --git a/cinelerra-5.1/plugins/stylizeobj/Makefile b/cinelerra-5.1/plugins/stylizeobj/Makefile
new file mode 100644 (file)
index 0000000..9e804ac
--- /dev/null
@@ -0,0 +1,21 @@
+default: all
+
+TOPDIR?=../..
+include $(TOPDIR)/plugin_defs
+
+PLUGIN = stylizeobj
+
+OBJS := \
+       $(OBJDIR)/stylizeobj.o \
+       $(OBJDIR)/stylizeobjwindow.o \
+
+want_var:=$(WANT_OPENCV)
+include $(TOPDIR)/opencv_build
+include $(TOPDIR)/plugin_config
+
+all:   opencv
+       +make $(OUTPUT)
+
+$(OBJDIR)/stylizeobj.o: stylizeobj.C stylizeobj.h stylizeobjwindow.h
+$(OBJDIR)/stylizeobjwindow.o: stylizeobjwindow.C stylizeobj.h stylizeobjwindow.h
+
diff --git a/cinelerra-5.1/plugins/stylizeobj/stylizeobj.C b/cinelerra-5.1/plugins/stylizeobj/stylizeobj.C
new file mode 100644 (file)
index 0000000..2d8b515
--- /dev/null
@@ -0,0 +1,216 @@
+/*
+ * CINELERRA
+ * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * 
+ */
+
+#include "clip.h"
+#include "filexml.h"
+#include "stylizeobj.h"
+#include "stylizeobjwindow.h"
+#include "language.h"
+#include "mutex.h"
+
+REGISTER_PLUGIN(StylizeObj)
+
+
+StylizeObjConfig::StylizeObjConfig()
+{
+       mode = MODE_EDGE_SMOOTH;
+       smoothing = 10;
+       edge_strength = 25;
+       shade_factor = 40;
+}
+
+int StylizeObjConfig::equivalent(StylizeObjConfig &that)
+{
+       return 1;
+}
+
+void StylizeObjConfig::copy_from(StylizeObjConfig &that)
+{
+}
+
+void StylizeObjConfig::interpolate( StylizeObjConfig &prev, StylizeObjConfig &next, 
+       long prev_frame, long next_frame, long current_frame)
+{
+       copy_from(next);
+}
+
+void StylizeObjConfig::limits()
+{
+}
+
+
+StylizeObj::StylizeObj(PluginServer *server)
+ : PluginVClient(server)
+{
+}
+
+StylizeObj::~StylizeObj()
+{
+}
+
+const char* StylizeObj::plugin_title() { return N_("StylizeObj"); }
+int StylizeObj::is_realtime() { return 1; }
+
+NEW_WINDOW_MACRO(StylizeObj, StylizeObjWindow);
+LOAD_CONFIGURATION_MACRO(StylizeObj, StylizeObjConfig)
+
+void StylizeObj::save_data(KeyFrame *keyframe)
+{
+       FileXML output;
+
+// cause data to be stored directly in text
+       output.set_shared_output(keyframe->get_data(), MESSAGESIZE);
+       output.tag.set_title("STYLIZEOBJ");
+       output.tag.set_property("MODE", config.mode);
+       output.tag.set_property("SMOOTHING", config.smoothing);
+       output.tag.set_property("EDGE_STRENGTH", config.edge_strength);
+       output.tag.set_property("SHADE_FACTOR", config.shade_factor);
+       output.append_tag();
+       output.append_newline();
+       output.tag.set_title("/STYLIZEOBJ");
+       output.append_tag();
+       output.append_newline();
+       output.terminate_string();
+}
+
+void StylizeObj::read_data(KeyFrame *keyframe)
+{
+       FileXML input;
+       input.set_shared_input(keyframe->get_data(), strlen(keyframe->get_data()));
+
+       int result = 0;
+       while( !(result = input.read_tag()) ) {
+               if( input.tag.title_is("STYLIZEOBJ") ) {
+                       config.mode          = input.tag.get_property("MODE", config.mode);
+                       config.smoothing     = input.tag.get_property("SMOOTHING", config.smoothing);
+                       config.edge_strength = input.tag.get_property("EDGE_STRENGTH", config.edge_strength);
+                       config.shade_factor  = input.tag.get_property("SHADE_FACTOR", config.shade_factor);
+                       config.limits();
+               }
+               else if( input.tag.title_is("/STYLIZEOBJ") )
+                       result = 1;
+       }
+}
+
+void StylizeObj::update_gui()
+{
+       if( !thread ) return;
+       if( !load_configuration() ) return;
+       thread->window->lock_window("StylizeObj::update_gui");
+       StylizeObjWindow *window = (StylizeObjWindow*)thread->window;
+       window->unlock_window();
+}
+
+void StylizeObj::to_mat(Mat &mat, int mcols, int mrows,
+       VFrame *inp, int ix,int iy, int mcolor_model)
+{
+       int mcomp = BC_CModels::components(mcolor_model);
+       int mbpp = BC_CModels::calculate_pixelsize(mcolor_model);
+       int psz = mbpp / mcomp;
+       int mdepth = psz < 2 ? CV_8U : psz < 4 ? CV_16U : CV_32F;
+       if( mat.dims != 2 || mat.depth() != mdepth || mat.channels() != mcomp ||
+           mat.cols != mcols || mat.rows != mrows ) {
+               mat.release();
+       }
+       if( mat.empty() ) {
+               int type = CV_MAKETYPE(mdepth, mcomp);
+               mat.create(mrows, mcols, type);
+       }
+       uint8_t *mat_rows[mrows];
+       for( int y=0; y<mrows; ++y ) mat_rows[y] = mat.ptr(y);
+       uint8_t **inp_rows = inp->get_rows();
+       int ibpl = inp->get_bytes_per_line(), mbpl = mcols * mbpp;
+       int icolor_model = inp->get_color_model();
+       BC_CModels::transfer(mat_rows, mcolor_model, 0,0, mcols,mrows, mbpl,
+               inp_rows, icolor_model, ix,iy, mcols,mrows, ibpl, 0);
+//     VFrame vfrm(mat_rows[0], -1, mcols,mrows, mcolor_model, mat_rows[1]-mat_rows[0]);
+//     static int vfrm_no = 0; char vfn[64]; sprintf(vfn,"/tmp/idat/%06d.png", vfrm_no++);
+//     vfrm.write_png(vfn);
+}
+
+void StylizeObj::from_mat(VFrame *out, int ox, int oy, int ow, int oh, Mat &mat, int mcolor_model)
+{
+       int mbpp = BC_CModels::calculate_pixelsize(mcolor_model);
+       int mrows = mat.rows, mcols = mat.cols;
+       uint8_t *mat_rows[mrows];
+       for( int y=0; y<mrows; ++y ) mat_rows[y] = mat.ptr(y);
+       uint8_t **out_rows = out->get_rows();
+       int obpl = out->get_bytes_per_line(), mbpl = mcols * mbpp;
+       int ocolor_model = out->get_color_model();
+       BC_CModels::transfer(out_rows, ocolor_model, ox,oy, ow,oh, obpl,
+               mat_rows, mcolor_model, 0,0, mcols,mrows, mbpl,  0);
+//     static int vfrm_no = 0; char vfn[64]; sprintf(vfn,"/tmp/odat/%06d.png", vfrm_no++);
+//     out->write_png(vfn);
+}
+
+
+int StylizeObj::process_buffer(VFrame *frame, int64_t start_position, double frame_rate)
+{
+
+       //int need_reconfigure =
+       load_configuration();
+       input = get_input(0);
+       output = get_output(0);
+       width = input->get_w();
+       height = input->get_h();
+       color_model = input->get_color_model();
+       VFrame *iframe = input;
+       read_frame(iframe, 0, start_position, frame_rate, 0);
+       int cv_color_model = BC_RGB888;
+       if( color_model != cv_color_model ) {
+               iframe = new_temp(width,height, cv_color_model);
+               iframe->transfer_from(input);
+       }
+
+// load next image
+       to_mat(next_img, width,height, iframe, 0,0, cv_color_model);
+       output->clear_frame();
+       Mat img, img1;
+       switch( config.mode ) {
+       case MODE_EDGE_SMOOTH:
+               edgePreservingFilter(next_img,img,1); // normalized conv filter
+               break;
+       case MODE_EDGE_RECURSIVE:
+               edgePreservingFilter(next_img,img,2); // recursive filter
+               break;
+       case MODE_DETAIL_ENHANCE:
+               detailEnhance(next_img,img);
+               break;
+       case MODE_PENCIL_SKETCH: {
+               float s = config.smoothing / 100;      s = s * s * 200;
+               float r = config.edge_strength / 100;  r = r * r;
+               float f = config.shade_factor / 100;   f = f * 0.1;
+               pencilSketch(next_img,img, img1, s, r, f);
+               cv_color_model = BC_GREY8;
+               break; }
+       case MODE_COLOR_SKETCH: {
+               float s = config.smoothing / 100;      s = s * s * 200;
+               float r = config.edge_strength / 100;  r = r * r;
+               float f = config.shade_factor / 100;   f = f * 0.1;
+               pencilSketch(next_img,img1, img, s, r, f);
+               break; }
+       case MODE_STYLIZATION:
+               stylization(next_img,img);
+               break;
+       }
+       from_mat(output, 0,0,width,height, img, cv_color_model);
+       return 0;
+}
+
diff --git a/cinelerra-5.1/plugins/stylizeobj/stylizeobj.h b/cinelerra-5.1/plugins/stylizeobj/stylizeobj.h
new file mode 100644 (file)
index 0000000..8f72193
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * CINELERRA
+ * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef STYLIZEOBJ_H
+#define STYLIZEOBJ_H
+
+#include "pluginvclient.h"
+#include "loadbalance.h"
+#include "mutex.inc"
+
+#include "opencv2/core/types.hpp"
+#include "opencv2/core/mat.hpp"
+#include "opencv2/calib3d.hpp"
+#include "opencv2/photo.hpp"
+#include "opencv2/video/video.hpp"
+
+#include <vector>
+
+using namespace std;
+using namespace cv;
+
+enum {
+ MODE_EDGE_SMOOTH,
+ MODE_EDGE_RECURSIVE,
+ MODE_DETAIL_ENHANCE,
+ MODE_PENCIL_SKETCH,
+ MODE_COLOR_SKETCH,
+ MODE_STYLIZATION,
+};
+
+class StylizeObjConfig;
+class StylizeObj;
+
+
+class StylizeObjConfig
+{
+public:
+       StylizeObjConfig();
+       int mode;
+       float smoothing, edge_strength, shade_factor;
+
+       int equivalent(StylizeObjConfig &that);
+       void copy_from(StylizeObjConfig &that);
+       void interpolate(StylizeObjConfig &prev, StylizeObjConfig &next, 
+               long prev_frame, long next_frame, long current_frame);
+       void limits();
+};
+
+class StylizeObj : public PluginVClient
+{
+public:
+       StylizeObj(PluginServer *server);
+       ~StylizeObj();
+       PLUGIN_CLASS_MEMBERS2(StylizeObjConfig)
+       int is_realtime();
+       void update_gui();
+       void save_data(KeyFrame *keyframe);
+       void read_data(KeyFrame *keyframe);
+       int process_buffer(VFrame *frame, int64_t start_position, double frame_rate);
+       void to_mat(Mat &mat, int mcols, int mrows,
+               VFrame *inp, int ix,int iy, int mcolor_model);
+       void from_mat(VFrame *out, int ox, int oy, int ow, int oh,
+               Mat &mat, int mcolor_model);
+
+       int width, height, color_model;
+       VFrame *input, *output;
+
+       Mat next_img;
+};
+
+#endif
diff --git a/cinelerra-5.1/plugins/stylizeobj/stylizeobjwindow.C b/cinelerra-5.1/plugins/stylizeobj/stylizeobjwindow.C
new file mode 100644 (file)
index 0000000..9b68d96
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * CINELERRA
+ * Copyright (C) 2014 Adam Williams <broadcast at earthling dot net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * 
+ */
+
+#include "bcdisplayinfo.h"
+#include "clip.h"
+#include "language.h"
+#include "stylizeobj.h"
+#include "stylizeobjwindow.h"
+#include "theme.h"
+
+StylizeObjWindow::StylizeObjWindow(StylizeObj *plugin)
+ : PluginClientWindow(plugin, 320, 160, 320, 160, 0)
+{
+       this->plugin = plugin; 
+       smoothing = 0;
+       edge_strength = 0;
+       shade_factor = 0;
+       smooth_title = 0;
+       edge_title = 0;
+       shade_title = 0;
+}
+
+StylizeObjWindow::~StylizeObjWindow()
+{
+}
+
+void StylizeObjWindow::create_objects()
+{
+       int x = 10, y = 10;
+       BC_Title *title = new BC_Title(x, y, _("StylizeObj"));
+       add_subwindow(title);
+       y += title->get_h() + 10;
+       int x1 = x;
+       add_subwindow(title = new BC_Title(x1, y, _("Mode: ")));
+       x1 += title->get_w() + 15;
+       add_subwindow(mode = new StylizeObjMode(this, x1, y, &plugin->config.mode));
+       mode->create_objects();
+       y += mode->get_h() + 10;
+       x0 = x;  y0 = y;
+       update_params();
+       show_window(1);
+}
+
+void StylizeObjWindow::update_params()
+{
+       int x = x0, y = y0;
+       if( plugin->config.mode == MODE_PENCIL_SKETCH ||
+           plugin->config.mode == MODE_COLOR_SKETCH ) {
+               int x1 = x + 80;
+               if( !smooth_title )
+                       add_subwindow(smooth_title = new BC_Title(x,y,_("Smooth:")));
+               if( !smoothing )
+                       add_subwindow(smoothing = new StylizeObjFSlider(this,
+                               x1,y,180, 0,100, &plugin->config.smoothing));
+               y += smoothing->get_h() + 10;
+               if( !edge_title )
+                       add_subwindow(edge_title = new BC_Title(x,y,_("Edges:")));
+               if( !edge_strength )
+                       add_subwindow(edge_strength = new StylizeObjFSlider(this,
+                               x1,y,180, 0,100, &plugin->config.edge_strength));
+               y += edge_strength->get_h() + 10;
+               if( !shade_title )
+                       add_subwindow(shade_title = new BC_Title(x,y,_("Shade:")));
+               if( !shade_factor )
+                       add_subwindow(shade_factor = new StylizeObjFSlider(this,
+                               x1,y,180, 0,100, &plugin->config.shade_factor));
+               //y += shade_factor->get_h() + 10;
+       }
+       else {
+               delete smooth_title;    smooth_title = 0;
+               delete smoothing;       smoothing = 0;
+               delete edge_title;      edge_title = 0;
+               delete edge_strength;   edge_strength = 0;
+               delete shade_title;     shade_title = 0;
+               delete shade_factor;    shade_factor = 0;
+       }
+}
+
+StylizeObjModeItem::StylizeObjModeItem(StylizeObjMode *popup, int type, const char *text)
+ : BC_MenuItem(text)
+{
+       this->popup = popup;
+       this->type = type;
+}
+
+StylizeObjModeItem::~StylizeObjModeItem()
+{
+}
+
+int StylizeObjModeItem::handle_event()
+{
+       popup->update(type);
+       popup->win->update_params();
+       return popup->handle_event();
+}
+
+StylizeObjMode::StylizeObjMode(StylizeObjWindow *win, int x, int y, int *value)
+ : BC_PopupMenu(x, y, 150, "", 1)
+{
+       this->win = win;
+       this->value = value;
+}
+
+StylizeObjMode::~StylizeObjMode()
+{
+}
+
+void StylizeObjMode::create_objects()
+{
+       add_item(new StylizeObjModeItem(this, MODE_EDGE_SMOOTH,    _("Edge smooth")));
+       add_item(new StylizeObjModeItem(this, MODE_EDGE_RECURSIVE, _("Edge recursive")));
+       add_item(new StylizeObjModeItem(this, MODE_DETAIL_ENHANCE, _("Detail Enhance")));
+       add_item(new StylizeObjModeItem(this, MODE_PENCIL_SKETCH,  _("Pencil Sketch")));
+       add_item(new StylizeObjModeItem(this, MODE_COLOR_SKETCH,   _("Color Sketch")));
+       add_item(new StylizeObjModeItem(this, MODE_STYLIZATION,    _("Stylization")));
+       set_value(*value);
+}
+
+int StylizeObjMode::handle_event()
+{
+       win->plugin->send_configure_change();
+       return 1;
+}
+
+void StylizeObjMode::update(int v)
+{
+       set_value(*value = v);
+}
+
+void StylizeObjMode::set_value(int v)
+{
+       int i = total_items();
+       while( --i >= 0 && ((StylizeObjModeItem*)get_item(i))->type != v );
+       if( i >= 0 ) set_text(get_item(i)->get_text());
+}
+
+StylizeObjFSlider::StylizeObjFSlider(StylizeObjWindow *win,
+               int x, int y, int w, float min, float max, float *output)
+ : BC_FSlider(x, y, 0,w,w, min,max, *output)
+{
+        this->win = win;
+        this->output = output;
+}
+StylizeObjFSlider::~StylizeObjFSlider()
+{
+}
+
+int StylizeObjFSlider::handle_event()
+{
+       *output = get_value();
+       win->plugin->send_configure_change();
+        return 1;
+}
+
diff --git a/cinelerra-5.1/plugins/stylizeobj/stylizeobjwindow.h b/cinelerra-5.1/plugins/stylizeobj/stylizeobjwindow.h
new file mode 100644 (file)
index 0000000..dab84d2
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * CINELERRA
+ * Copyright (C) 2008-2014 Adam Williams <broadcast at earthling dot net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * 
+ */
+
+#ifndef STYLIZEOBJWINDOW_H
+#define STYLIZEOBJWINDOW_H
+
+
+#include "guicast.h"
+
+class StylizeObj;
+class StylizeObjWindow;
+class StylizeObjModeItem;
+class StylizeObjMode;
+class StylizeObjFSlider;
+
+class StylizeObjModeItem : public BC_MenuItem
+{
+public:
+       StylizeObjModeItem(StylizeObjMode *popup, int type, const char *text);
+       ~StylizeObjModeItem();
+       int handle_event();
+
+       StylizeObjMode *popup;
+       int type;
+};
+
+class StylizeObjMode : public BC_PopupMenu
+{
+public:
+       StylizeObjMode(StylizeObjWindow *win, int x, int y, int *value);
+       ~StylizeObjMode();
+       void create_objects();
+       int handle_event();
+       void update(int v);
+       void set_value(int v);
+
+       StylizeObjWindow *win;
+       int *value;
+};
+
+class StylizeObjFSlider : public BC_FSlider
+{
+public:
+       StylizeObjFSlider(StylizeObjWindow *win,
+               int x, int y, int w, float min, float max, float *output);
+       ~StylizeObjFSlider();
+       int handle_event();
+
+       StylizeObjWindow *win;
+       float *output;
+};
+
+class StylizeObjWindow : public PluginClientWindow
+{
+public:
+       StylizeObjWindow(StylizeObj *plugin);
+       ~StylizeObjWindow();
+
+       void create_objects();
+       void update_params();
+       int x0, y0;
+
+       StylizeObj *plugin;
+       StylizeObjMode *mode;
+       BC_Title *smooth_title;
+       BC_Title *edge_title;
+       BC_Title *shade_title;
+       StylizeObjFSlider *smoothing;
+       StylizeObjFSlider *edge_strength;
+       StylizeObjFSlider *shade_factor;
+};
+
+#endif