title: multiprocessing.pool.RemoteTraceback, TypeError: Incorrect type of self (must be 'Feature2D' or its derivative)
body: <p>I want to calculate keypoints and descriptors with openCV brisk using python multiprocessing. When I run the following codes, some errors happened.But when I run the codes with python threading, it will be OK.</p>
  
  <pre><code>import cv2
  import os
  from multiprocessing import Pool
  
  
  class Test:
      def __init__(self):
          self.brisk = cv2.BRISK_create(thresh=70, octaves=4)
  
      def apply_brisk(self, test_img_path):
          # brisk = cv2.BRISK_create(thresh=70, octaves=4)
  
          frame = cv2.imread(test_img_path)
          img_gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
          img_kp = self.brisk.detect(img_gray, None)
          img_kp, img_des = self.brisk.compute(img_gray, img_kp)
          print(img_kp)
          print(img_des)
  
  
  if __name__ == '__main__':
      # test images directory
      test_images_dir = '/home/limin/pcb/images'
      test_images_name = [f for f in os.listdir(test_images_dir)]
  
      p = Pool(4)
      for test in test_images_name:
          # test image path
          test_image_path = test_images_dir + '/' + test
  
          t = Test()
          p.apply(t.apply_brisk, (test_image_path,))
          # p.apply_async(t.apply_brisk, (test_image_path,))
  
      p.close()
      p.join()
  </code></pre>
  
  <p><strong>Errors:</strong> <br></p>
  
  <pre><code>multiprocessing.pool.RemoteTraceback: 
  """
  Traceback (most recent call last):
    File "/usr/lib/python3.5/multiprocessing/pool.py", line 119, in worker
      result = (True, func(*args, **kwds))
    File "/home/limin/Desktop/classifier_cv_tf/test.py", line 15, in apply_brisk
      img_kp = self.brisk.detect(img_gray, None)
  TypeError: Incorrect type of self (must be 'Feature2D' or its derivative)
  """
  
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
    File "/home/limin/Desktop/classifier_cv_tf/test.py", line 32, in &lt;module&gt;
      p.apply(t.apply_brisk, (test_image_path,))
    File "/usr/lib/python3.5/multiprocessing/pool.py", line 253, in apply
      return self.apply_async(func, args, kwds).get()
    File "/usr/lib/python3.5/multiprocessing/pool.py", line 608, in get
      raise self._value
  TypeError: Incorrect type of self (must be 'Feature2D' or its derivative)
  </code></pre>
  
  <p>When I change the position of 'BRISK' object, errors will missing:</p>
  
  <pre><code>import cv2
  import os
  from multiprocessing import Pool
  
  
  class Test:
      def __init__(self):
          # self.brisk = cv2.BRISK_create(thresh=70, octaves=4)
          pass
  
      def apply_brisk(self, test_img_path):
          brisk = cv2.BRISK_create(thresh=70, octaves=4)
  
          frame = cv2.imread(test_img_path)
          img_gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
          img_kp = brisk.detect(img_gray, None)
          img_kp, img_des = brisk.compute(img_gray, img_kp)
          print(img_kp)
          print(img_des)
  
  
  if __name__ == '__main__':
      # test images directory
      test_images_dir = '/home/limin/pcb/images'
      test_images_name = [f for f in os.listdir(test_images_dir)]
  
      p = Pool(4)
      for test in test_images_name:
          # test image path
          test_image_path = test_images_dir + '/' + test
  
          t = Test()
          p.apply(t.apply_brisk, (test_image_path,))
          # p.apply_async(t.apply_brisk, (test_image_path,))
  
      p.close()
      p.join()
  </code></pre>
  
  <p><strong>Environments:</strong> <br></p>
  
  <ul>
  <li>Ubuntu16.04</li>
  <li>python3.5</li>
  <li>opencv3.4.8</li>
  </ul>
  
  <p>I am wondering about this, who can help me if I want to use python multiprocessing in the codes. Thank you! </p>