title: Python & OpenCV
body: <p>Is there any Native Supports for Grabbing Images from PDFs or Create some sort of Object in Python that can contain the Images from a pdf that then can be access via OpenCV? I've looked at some scripts to dump the Images of a PDF into my directory but I'm aiming more at accessing the PDF and instead dumping the data from the PDF that is the image(s) into some sort of object I can access with OpenCV. My own exploration hasn't yielded any results so i figured I'd ask.</p>
  
  <p>Added a Example of Using PyMuPDF based off example from @Ghilas BELHADJ</p>
  
  <pre><code>import fitz
  import cv2
  import numpy as np
  from tkinter import Tk
  from tkinter.filedialog import askopenfilename
  
  
  class AccessPDF:
  
      def __init__(self):
          self.filepath = ""
          self.doc = None
  
      def openPDF(self):
          Tk().withdraw()
          self.filepath = askopenfilename()
          self.doc = fitz.open(self.filepath)
  
      def pixel2np(self,pix):
          im = np.frombuffer(pix.samples, dtype=np.uint8).reshape(pix.h, pix.w, pix.n)
          im = np.ascontiguousarray(im[..., [2, 1, 0]])  # rgb to bgr
          return im
  
      def displayKey(self):  
          pixobj = self.doc.getPagePixmap(0, alpha=False)
          im = self.pixel2np(pixobj)
          cv2.imwrite("testimg.png",im)
          cv2.imshow("Key" im)
  </code></pre>