From 77c5d18916638c54a3866ccb6848cb608b211382 Mon Sep 17 00:00:00 2001
From: zhangmeng <775834166@qq.com>
Date: 星期三, 09 十月 2019 15:56:08 +0800
Subject: [PATCH] add resize
---
csrc/wrapper.cpp | 4 ++++
goconv.go | 25 +++++++++++++++++++++++++
2 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/csrc/wrapper.cpp b/csrc/wrapper.cpp
index 2643ce0..5d63805 100644
--- a/csrc/wrapper.cpp
+++ b/csrc/wrapper.cpp
@@ -437,6 +437,10 @@
void *CreateConvertor(const int srcW, const int srcH, const int srcFormat,
const int dstW, const int dstH, const int flag){
AVPixelFormat pix_fmt = AV_PIX_FMT_BGR24;
+ // just resize
+ if (flag == 0){
+ pix_fmt = (AVPixelFormat)srcFormat;
+ }
auto bridge = new cvbridge(
srcW, srcH, srcFormat,
dstW, dstH, pix_fmt, flag);
diff --git a/goconv.go b/goconv.go
index 459b3dd..a120b2a 100644
--- a/goconv.go
+++ b/goconv.go
@@ -64,6 +64,23 @@
}
}
+// NewResizer resize
+func NewResizer(srcW, srcH, dstW, dstH int) *GoConv {
+ c := C.wrap_fn_create_conv(C.int(srcW), C.int(srcH), C.int(srcFormat), C.int(dstW), C.int(dstH), ScaleNone)
+
+ if c == nil {
+ return nil
+ }
+
+ return &GoConv{
+ srcW,
+ srcH,
+ dstW,
+ dstH,
+ c,
+ }
+}
+
// Free free
func (c *GoConv) Free() {
if c.conv != nil {
@@ -90,6 +107,14 @@
return nil
}
+// Resize resize
+func (c *GoConv) Resize(src []byte) []byte {
+ if c.srcW == c.dstW && c.srcH == c.dstH {
+ return src
+ }
+ return c.ConvToPicture(src)
+}
+
/////////////// for conv
// ConvGPU conv gpu resize
--
Gitblit v1.8.0