From 4645b3c0b7256990cf4f1c808ff37217f0db3fc9 Mon Sep 17 00:00:00 2001 From: Good Guy Date: Thu, 22 Nov 2018 20:33:49 -0700 Subject: [PATCH] opencv v4 breaks findobj - no upgrade, sketcher tweaks --- cinelerra-5.1/opencv_build | 4 ++++ cinelerra-5.1/plugins/findobj/findobj.h | 1 + cinelerra-5.1/plugins/sketcher/sketcher.C | 25 +++++++++++------------ cinelerra-5.1/plugins/sketcher/sketcher.h | 1 + 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/cinelerra-5.1/opencv_build b/cinelerra-5.1/opencv_build index 73e2da52..612e4d29 100644 --- a/cinelerra-5.1/opencv_build +++ b/cinelerra-5.1/opencv_build @@ -46,6 +46,8 @@ opencv_tar:=$(notdir $(tar_url)) cpus:=$(shell grep -c "^proc" /proc/cpuinfo) jobs:=-j$(shell echo $$(($(cpus) + $(cpus)/2 +2))) +#opencv4 breaks SIFT/SURF findobj +#CFLAGS += -I$(opencv_prefix)/include/opencv4 CFLAGS += -I$(opencv_prefix)/include ifeq ($(src),git) @@ -82,6 +84,8 @@ $(opencv)/build: $(opencv).src LFLAGS += -Wl,--start-group LFLAGS += $(shell find $(opencv_prefix)/lib* -name "libopencv_*.a" 2> /dev/null) +#opencv4 breaks SIFT/SURF findobj +#LFLAGS += $(shell find $(opencv_prefix)/lib64/opencv4/3rdparty/lib* -name "lib*.a" 2> /dev/null) LFLAGS += $(shell find $(opencv_prefix)/share/OpenCV/3rdparty/lib* -name "lib*.a" 2> /dev/null) LFLAGS += -Wl,--end-group else ifeq ($(bld),dyn) diff --git a/cinelerra-5.1/plugins/findobj/findobj.h b/cinelerra-5.1/plugins/findobj/findobj.h index d27ac056..8510cd9d 100644 --- a/cinelerra-5.1/plugins/findobj/findobj.h +++ b/cinelerra-5.1/plugins/findobj/findobj.h @@ -63,6 +63,7 @@ using namespace cv::xfeatures2d; using namespace cvflann; // enabled detectors +// _SIFT/_SURF are broken in v4, although they work in v3, no upgrade #define _SIFT #define _SURF #define _ORB diff --git a/cinelerra-5.1/plugins/sketcher/sketcher.C b/cinelerra-5.1/plugins/sketcher/sketcher.C index 9bbdd675..70da9eb2 100644 --- a/cinelerra-5.1/plugins/sketcher/sketcher.C +++ b/cinelerra-5.1/plugins/sketcher/sketcher.C @@ -100,7 +100,7 @@ void SketcherCurve::init(int id, int pen, int width, int color) } SketcherCurve::SketcherCurve(int id) { - init(id, 1, ARC_LINE, CV_COLOR); + init(id, 1, PEN_SQUARE, CV_COLOR); } SketcherCurve::SketcherCurve(int id, int pen, int width, int color) { @@ -346,6 +346,7 @@ Sketcher::~Sketcher() const char* Sketcher::plugin_title() { return N_("Sketcher"); } int Sketcher::is_realtime() { return 1; } +int Sketcher::is_synthesis() { return 1; } NEW_WINDOW_MACRO(Sketcher, SketcherWindow); LOAD_CONFIGURATION_MACRO(Sketcher, SketcherConfig) @@ -526,7 +527,6 @@ static void smooth_dxy(float &dx, float &dy, dx = xc - xd; dy = yc - yd; } -#if 0 static int convex(float ax,float ay, float bx,float by, float cx,float cy, float dx,float dy) { @@ -539,8 +539,6 @@ static int convex(float ax,float ay, float bx,float by, float v = abc * bcd; return !v ? 0 : v>0 ? 1 : -1; } -#endif - class FillRegion { @@ -622,13 +620,12 @@ void FillRegion::run() SketcherPoint *FillRegion::next() { while( nxt < points.size() ) { - SketcherPoint *pt = points[nxt]; + SketcherPoint *pt = points[nxt++]; if( pt->arc == ARC_OFF ) continue; - if( pt->arc != ARC_FILL ) break; + if( pt->arc != ARC_FILL ) return pt; start_at(pt->x, pt->y); - ++nxt; } - return nxt < points.size() ? points[nxt++] : 0; + return 0; } @@ -651,14 +648,16 @@ void SketcherCurve::draw(VFrame *img) while( pt2 ) { dx = pt2->x; dy = pt2->y; switch( pt0->arc ) { + case ARC_CURVE: + if( convex(ax,ay, bx,by, cx,cy, dx,dy) >= 0 ) { + // s = ac thru b x bd thru c + intersects_at(sx,sy, ax,ay,cx,cy,bx,by, bx,by,dx,dy,cx,cy,fmx); + vpen->draw_smooth(bx,by, sx,sy, cx,cy); + break; + } // fall thru case ARC_LINE: vpen->draw_line(bx, by, cx, cy); break; - case ARC_CURVE: { - // s = ac thru b x bd thru c - intersects_at(sx,sy, ax,ay,cx,cy,bx,by, bx,by,dx,dy,cx,cy,fmx); - vpen->draw_smooth(bx,by, sx,sy, cx,cy); - break; } } ax = bx; ay = by; pt0 = pt1; bx = cx; by = cy; pt1 = pt2; diff --git a/cinelerra-5.1/plugins/sketcher/sketcher.h b/cinelerra-5.1/plugins/sketcher/sketcher.h index 3df08768..1ddd5a47 100644 --- a/cinelerra-5.1/plugins/sketcher/sketcher.h +++ b/cinelerra-5.1/plugins/sketcher/sketcher.h @@ -176,6 +176,7 @@ public: ~Sketcher(); PLUGIN_CLASS_MEMBERS2(SketcherConfig) int is_realtime(); + int is_synthesis(); void update_gui(); void save_data(KeyFrame *keyframe); void read_data(KeyFrame *keyframe); -- 2.26.2