summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Santos <ts.santos@sisa.samsung.com>2014-04-04 11:50:58 -0300
committerThiago Santos <thiagoss@osg.samsung.com>2014-07-31 18:42:16 -0300
commitfa6567b33f55ff41e81dba1aafb0c524867f6bb4 (patch)
tree08a984cf54b1f771281483e59deda1e9000d4fe4
parente60553b19146105db6ccd9924ebba0989fce6910 (diff)
tesseractocr: use recommended free function according to api docstesseract
-rw-r--r--ext/tesseractocr/gsttesseractocr.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/ext/tesseractocr/gsttesseractocr.cpp b/ext/tesseractocr/gsttesseractocr.cpp
index d9d12d645..5b87441bf 100644
--- a/ext/tesseractocr/gsttesseractocr.cpp
+++ b/ext/tesseractocr/gsttesseractocr.cpp
@@ -260,6 +260,12 @@ gst_tesseract_ocr_sink_event (GstPad * pad, GstObject * parent,
return ret;
}
+static void
+_tesseract_ocr_free_text (gpointer data)
+{
+ delete [] (char *) data;
+}
+
static GstFlowReturn
gst_tesseract_ocr_sink_chain (GstPad * pad, GstObject * parent,
GstBuffer * buffer)
@@ -267,6 +273,7 @@ gst_tesseract_ocr_sink_chain (GstPad * pad, GstObject * parent,
GstTesseractOcr *tesseractocr;
GstMapInfo info;
gchar *text;
+ gint text_len;
GstBuffer *out_buffer;
tesseractocr = GST_TESSERACT_OCR (parent);
@@ -292,9 +299,10 @@ gst_tesseract_ocr_sink_chain (GstPad * pad, GstObject * parent,
GST_VIDEO_INFO_PLANE_STRIDE (&tesseractocr->vinfo, 0));
text = tesseractocr->api->GetUTF8Text ();
- out_buffer = gst_buffer_new_wrapped (text, strlen (text));
- /* TODO this 'text' variable should be freed with delete[]
- * according to tesseract docs */
+ text_len = strlen (text);
+ out_buffer = gst_buffer_new_wrapped_full ((GstMemoryFlags) 0,
+ text, text_len + 1,
+ 0, text_len + 1, text, _tesseract_ocr_free_text);
GST_DEBUG_OBJECT (tesseractocr, "found text '%s'", text);