项目作者: sleepbysleep

项目描述 :
Surface inspection software using Flir(previously PointGrey) USB3 camera with Spinnaker SDK, and python(1.26.0.31), which provides Color Correction, Lens Distortion Correction, Multiple ROI processing, and Binarization in the way of WIGZIG.
高级语言: Python
项目地址: git://github.com/sleepbysleep/surface_inspector.git
创建时间: 2019-10-16T07:47:38Z
项目社区:https://github.com/sleepbysleep/surface_inspector

开源协议:

下载


surface_inspector

Python code for surface inspection is supposed to used especially for agricultural products, which requires Flir(previously PointGrey) USB3 camera with Spinnaker SDK, and PySpin, python module(1.26.0.31) with Opencv, PyQt5, PySerial, and etc.
It is capable of Color Correction, Binarization, Lens Distortion Correction, and multiple ROI processing.
The color Correction is implemented with OpenCV.mcc and OpenCV.ccm (i.e. Color Correction matrix) from MecBeth Color Chart.
As well as the Lens Distortion Correction provides generic model as options of fisheye, and omnidirectional model in the form of modified opencv ccalib package.
The Binarization is capable of look and feel control by RangeSlider with sliding both of lower, and higher values.

Screenshot

Calibration Panel

alt ROI Setting + Calibration

Binarization Penel

alt ROI Setting + Binarization

Setting Panel for tuning camera

alt ROI Setting + Camera Setting

Dependencies

1. Install Spinnaker SDK.

1.1. The dependencies.

  1. $ apt install libavcodec-ffmpeg56 libavformat-ffmpeg56 libswscale-ffmpeg3 libswresample-ffmpeg1 libavutil-ffmpeg54 libusb-1.0-0 libgtkmm-2.4-dev
#### 1.1.1. Workaround
  1. $ vi /etc/apt/source.list
  2. deb http://debian-archive.trafficmanager.net/debian/ stretch main
  3. $ apt update
  4. $ apt install libswscale4 libavcodec57 libavformat57
### 1.2. Spinnaker
  1. $ sh install_spinnaker.sh
  2. This is a script to assist with installation of the Spinnaker SDK.
  3. Would you like to continue and install all the Spinnaker SDK packages?
  4. [Y/n] $
  5. Installing Spinnaker packages...
  6. Selecting previously unselected package libspinnaker1-dev.
  7. (Reading database ... 431320 files and directories currently installed.)
  8. Preparing to unpack libspinnaker-1.26.0.31_amd64-dev.deb ...
  9. Unpacking libspinnaker1-dev (1.26.0.31) ...
  10. Selecting previously unselected package libspinnaker1.
  11. Preparing to unpack libspinnaker-1.26.0.31_amd64.deb ...
  12. Unpacking libspinnaker1 (1.26.0.31) ...
  13. Selecting previously unselected package libspinnaker-c1-dev.
  14. Preparing to unpack libspinnaker-c-1.26.0.31_amd64-dev.deb ...
  15. Unpacking libspinnaker-c1-dev (1.26.0.31) ...
  16. Selecting previously unselected package libspinnaker-c1.
  17. Preparing to unpack libspinnaker-c-1.26.0.31_amd64.deb ...
  18. Unpacking libspinnaker-c1 (1.26.0.31) ...
  19. Setting up libspinnaker1 (1.26.0.31) ...
  20. Setting up libspinnaker-c1 (1.26.0.31) ...
  21. Setting up libspinnaker1-dev (1.26.0.31) ...
  22. Setting up libspinnaker-c1-dev (1.26.0.31) ...
  23. Selecting previously unselected package libspinvideo1-dev.
  24. (Reading database ... 431571 files and directories currently installed.)
  25. Preparing to unpack libspinvideo-1.26.0.31_amd64-dev.deb ...
  26. Unpacking libspinvideo1-dev (1.26.0.31) ...
  27. Selecting previously unselected package libspinvideo1.
  28. Preparing to unpack libspinvideo-1.26.0.31_amd64.deb ...
  29. Unpacking libspinvideo1 (1.26.0.31) ...
  30. Selecting previously unselected package libspinvideo-c1-dev.
  31. Preparing to unpack libspinvideo-c-1.26.0.31_amd64-dev.deb ...
  32. Unpacking libspinvideo-c1-dev (1.26.0.31) ...
  33. Selecting previously unselected package libspinvideo-c1.
  34. Preparing to unpack libspinvideo-c-1.26.0.31_amd64.deb ...
  35. Unpacking libspinvideo-c1 (1.26.0.31) ...
  36. Setting up libspinvideo1-dev (1.26.0.31) ...
  37. Setting up libspinvideo1 (1.26.0.31) ...
  38. Setting up libspinvideo-c1-dev (1.26.0.31) ...
  39. Setting up libspinvideo-c1 (1.26.0.31) ...
  40. Selecting previously unselected package spinview-qt1-dev.
  41. (Reading database ... 431656 files and directories currently installed.)
  42. Preparing to unpack spinview-qt-1.26.0.31_amd64-dev.deb ...
  43. Unpacking spinview-qt1-dev (1.26.0.31) ...
  44. Selecting previously unselected package spinview-qt1.
  45. Preparing to unpack spinview-qt-1.26.0.31_amd64.deb ...
  46. Unpacking spinview-qt1 (1.26.0.31) ...
  47. Setting up spinview-qt1-dev (1.26.0.31) ...
  48. Setting up spinview-qt1 (1.26.0.31) ...
  49. ldconfig: /lib/libicuuc.so.56 is not a symbolic link
  50. ldconfig: /lib/libQt5Network.so.5 is not a symbolic link
  51. ldconfig: /lib/libicudata.so.56 is not a symbolic link
  52. ldconfig: /lib/libicui18n.so.56 is not a symbolic link
  53. ldconfig: /lib/libQt5Widgets.so.5 is not a symbolic link
  54. ldconfig: /lib/libQt5XcbQpa.so.5 is not a symbolic link
  55. ldconfig: /lib/libQt5Core.so.5 is not a symbolic link
  56. ldconfig: /lib/libQt5OpenGL.so.5 is not a symbolic link
  57. ldconfig: /lib/libQt5Gui.so.5 is not a symbolic link
  58. ldconfig: /lib/libQt5DBus.so.5 is not a symbolic link
  59. Processing triggers for mime-support (3.64) ...
  60. Processing triggers for desktop-file-utils (0.24-1) ...
  61. Selecting previously unselected package spinupdate1-dev.
  62. (Reading database ... 431768 files and directories currently installed.)
  63. Preparing to unpack spinupdate-1.26.0.31_amd64-dev.deb ...
  64. Unpacking spinupdate1-dev (1.26.0.31) ...
  65. Selecting previously unselected package spinupdate1.
  66. Preparing to unpack spinupdate-1.26.0.31_amd64.deb ...
  67. Unpacking spinupdate1 (1.26.0.31) ...
  68. Setting up spinupdate1-dev (1.26.0.31) ...
  69. Setting up spinupdate1 (1.26.0.31) ...
  70. ldconfig: /lib/libicuuc.so.56 is not a symbolic link
  71. ldconfig: /lib/libQt5Network.so.5 is not a symbolic link
  72. ldconfig: /lib/libicudata.so.56 is not a symbolic link
  73. ldconfig: /lib/libicui18n.so.56 is not a symbolic link
  74. ldconfig: /lib/libQt5Widgets.so.5 is not a symbolic link
  75. ldconfig: /lib/libQt5XcbQpa.so.5 is not a symbolic link
  76. ldconfig: /lib/libQt5Core.so.5 is not a symbolic link
  77. ldconfig: /lib/libQt5OpenGL.so.5 is not a symbolic link
  78. ldconfig: /lib/libQt5Gui.so.5 is not a symbolic link
  79. ldconfig: /lib/libQt5DBus.so.5 is not a symbolic link
  80. Selecting previously unselected package spinnaker.
  81. (Reading database ... 431810 files and directories currently installed.)
  82. Preparing to unpack spinnaker-1.26.0.31_amd64.deb ...
  83. Unpacking spinnaker (1.26.0.31) ...
  84. Selecting previously unselected package spinnaker-doc.
  85. Preparing to unpack spinnaker-doc-1.26.0.31_amd64.deb ...
  86. Unpacking spinnaker-doc (1.26.0.31) ...
  87. Setting up spinnaker (1.26.0.31) ...
  88. Setting up spinnaker-doc (1.26.0.31) ...
  89. Processing triggers for mime-support (3.64) ...
  90. Processing triggers for desktop-file-utils (0.24-1) ...
  91. Would you like to add a udev entry to allow access to USB hardware?
  92. If this is not ran then your cameras may be only accessible by running Spinnaker as sudo.
  93. [Y/n] $ Y
  94. Launching udev configuration script...
  95. This script will assist users in configuring their udev rules to allow
  96. access to USB devices. The script will create a udev rule which will
  97. add FLIR USB devices to a group called flirimaging. The user may also
  98. choose to restart the udev daemon. All of this can be done manually as well.
  99. Adding new members to usergroup flirimaging...
  100. Usergroup flirimaging is empty
  101. To add a new member please enter username (or hit Enter to continue):
  102. $ (my_username)
  103. ....
Follow the instructions. #### 1.2.1. Modify the USB-FS memory in Linux.
  1. $ vi /etc/default/grub
  2. GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
  3. as
  4. GRUB_CMDLINE_LINUX_DEFAULT="quiet splash usbcore.usbfs_memory_mb=1000"
  5. $ update-grub
  6. $ reboot

1.2.2. Increase the receive buffer size

  1. $ vi /etc/sysctl.conf
  2. net.core.rmem_max=10485760
  3. net.core.rmem_default=10485760
  4. $ sysctl -p

2. Install Spinnaker python module.

2.1. Create virtualenv.

  1. $ python3.7 -m venv ./venv
  2. $ source ./venv/bin/activate

2.2. Dependencies.

  1. (venv)$ pip install -U numpy
### 2.3. Spinnaker.
  1. (venv)$ pip install spinnaker_python-1.26.0.31-cp37-cp37m-linux_x86_64.whl

3. Install python-dependencies.

  1. (venv)$ pip install PyQt5 pyserial construct PyCRC