remove filepng little-endian, reactivate sift in opencv
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / findobj / findobj.C
index ea1d60180c887f2c5397be48632cd7859ee87a14..c445bff37a69ad2d986c9966cf4c85d96ba55eb7 100644 (file)
@@ -21,6 +21,8 @@
 #include "affine.h"
 #include "bccolors.h"
 #include "clip.h"
+#include "edl.h"
+#include "edlsession.h"
 #include "filexml.h"
 #include "language.h"
 #include "findobj.h"
@@ -30,6 +32,7 @@
 #include "plugin.h"
 #include "pluginserver.h"
 #include "track.h"
+#include "tracks.h"
 
 #include <errno.h>
 #include <exception>
@@ -311,6 +314,13 @@ void FindObjMain::read_data(KeyFrame *keyframe)
        config.boundaries();
 }
 
+Track *FindObjMain::get_plugin_track()
+{
+        int plugin_id = server->plugin_id;
+        Plugin *plugin = server->edl->tracks->plugin_exists(plugin_id);
+        return !plugin ? 0 : plugin->track;
+}
+
 void FindObjMain::draw_line(VFrame *vframe, int x1, int y1, int x2, int y2)
 {
        vframe->draw_line(x1, y1, x2, y2);
@@ -412,7 +422,7 @@ void FindObjMain::detect(Mat &mat, KeyPointV &keypts,Mat &descrs)
        descrs.release();
        try {
                detector->detectAndCompute(mat, noArray(), keypts, descrs);
-       } catch(std::exception e) { printf(_("detector exception: %s\n"), e.what()); }
+       } catch(std::exception &e) { printf(_("detector exception: %s\n"), e.what()); }
 }
 
 void FindObjMain::match()
@@ -420,7 +430,7 @@ void FindObjMain::match()
        pairs.clear();
        try {
                matcher->knnMatch(obj_descrs, scn_descrs, pairs, 2);
-       } catch(std::exception e) { printf(_("match execption: %s\n"), e.what()); }
+       } catch(std::exception &e) { printf(_("match execption: %s\n"), e.what()); }
 }
 
 Ptr<DescriptorMatcher> FindObjMain::flann_kdtree_matcher()
@@ -494,7 +504,6 @@ void FindObjMain::set_brisk()
 }
 #endif
 
-
 void FindObjMain::process_match()
 {
        if( config.algorithm == NO_ALGORITHM ) return;
@@ -717,9 +726,9 @@ int FindObjMain::process_buffer(VFrame **frame, int64_t start_position, double f
        object_layer = config.object_layer;
        scene_layer = config.scene_layer;
        replace_layer = config.replace_layer;
-       Track *track = server->plugin->track;
-       w = track->track_w;
-       h = track->track_h;
+       Track *track = get_plugin_track();
+       w = track ? track->track_w : get_edl()->session->output_w;
+       h = track ? track->track_h : get_edl()->session->output_h;
 
        int max_layer = PluginClient::get_total_buffers() - 1;
        object_layer = bclip(config.object_layer, 0, max_layer);