douchilian1009 2014-09-23 16:06
浏览 37

Go中没有SWIG和第三方lib的OpenCV

Main goal: Make OpenCV work in Go without SWIG and third party lib (an application to compare image in linux using Go)

I am new in all the kits (OpenCv Go and linux)

  1. Can image detection (feature2d etc) can be done by C-api only? There is no convenient way to call C++ code and C-api is not updated(?)

  2. I have followed How to use C++ in Go? but I failed. When I make, I got the following errors

makefile:5: /usr/local/go/bin/src/Make.amd64: No such file or directory
makefile:6: /usr/local/go/bin/src/Make.pkg: No such file or directory
makefile:8: *
missing separator. Stop.

The makefile is as followed

GOROOT=/usr/local/go/bin  
   GOARCH=amd64  
   TARG=foo  
   CGOFILES=foo.go  
   include $(GOROOT)/src/Make.$(GOARCH)  
   include $(GOROOT)/src/Make.pkg  
   foo.o:foo.cpp  
   g++ $(_CGO_CFLAGS_$(GOARCH)) -fPIC -O2 -o $@ -c $(CGO_CFLAGS) $<  
   cfoo.o:cfoo.cpp  
   g++ $(_CGO_CFLAGS_$(GOARCH)) -fPIC -O2 -o $@ -c $(CGO_CFLAGS) $<  
   CGO_LDFLAGS+=-lstdc++  
   $(elem)_foo.so: foo.cgo4.o foo.o cfoo.o  
   gcc $(_CGO_CFLAGS_$(GOARCH)) $(_CGO_LDFLAGS_$(GOOS)) -o $@ $^ $(CGO_LDFLAGS)  

Thanks a lot

  • 写回答

2条回答 默认 最新

  • doudun2212 2014-09-23 16:25
    关注

    You can't call C++ code without either writing C wrappers (+ cgo) yourself or using SWIG, that's just the way it is sadly.

    That post you linked is extremely outdated and can't be used anymore.

    On the other hand, you can always start rewriting opencv in pure go, the speed differences won't be that massive, specially if you learn how to use unsafe for the speed-critical parts.

    disclaimer using unsafe is not advised since, well, it's unsafe.

    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)