《工业视觉系统中的跨语言集成-杨权.pptx》由会员分享,可在线阅读,更多相关《工业视觉系统中的跨语言集成-杨权.pptx(12页珍藏版)》请在三个皮匠报告上搜索。
1、工业视觉系统中的跨语言集成:Python与C+的完美结合Cross-Language Integration in Industrial Vision Systems:The Perfect Blend of Python and C+个人介绍/About 世界上最好的编程语言CMatlabC+JavaJavaScriptbashPythonC+The best programming language in the world不存在/Doesnt exist yet工业视觉系统/Machine Vision Systems光源/Illumination镜头和相机Camera&Lens计算机C
2、omputer待测物体/Object传送剔除系统Conveyer systemsNGOK光+机+电+软optical+mechanical+electrical+softwareOKNGNot Good常用的技术栈和架构Commonly used tech stack and architectureProducerProducerqueueConsumerConsumer慢就是快?/Slower is faster?业务场景分散半导体、玻璃、塑料、柔性材料、印刷品定制需求多这种缺陷不检、这个面不检、换产品了耗时耗力光学、机械、电气、算法、开发、产品经理、项目经理全一套预算还没下来开发效率偏慢
3、错误难定位第三方库管理不方便文档难读期待的技术栈Electron ctypes/cffi/CPPYY CPython/PyBind11/Boost.Python Cython SWIG前端/Front end后端/Back endThe Expected tech stack外部函数调用/Foreign Function Interface 调用现成的库 适合相机驱动、运动控制等模块from ctypes import WinDLLdll=WinDLL(GxIAPI.dll,winmode=0)if hasattr(dll,GXInitLib):result=dll.GXInitLib()fr
4、om cffi import FFIffi=FFI()ffi.cdef(int GXInitLib();)lib=ffi.dlopen(GxIAPI.dll)result=lib.GXInitLib()import cppyycppyy.include(GalaxyIncludes.h)cppyy.load_library(GxIAPICPPEx.dll)cppyy.gbl.GX_STATUS_LISTcffictypescppyy模块扩展/extending modules 更灵活的集成 适合算法加速、模块封装#include#include#include static PyObject*
5、create_instance(PyObject*self,PyObject*args)static PyObject*call_segment(PyObject*self,PyObject*args)static PyMethodDef image_segment_methods=;static struct PyModuleDef image_segment=;PyMODINIT_FUNC PyInit_myModule(void)#include#include#include namespace py=pybind11;PYBIND11_MODULE(image_segment,m)p
6、y:class_(m,Segmentor).def(py:init().def(segment,&Segmentor:segment);#include#include#include namespace np=boost:python:numpy;BOOST_PYTHON_MODULE(image_segment)using namespace boost:python;class_(Segmentor,init().def(segment,&Segmentor:segme