title: "Windows fatal exception: access violation" error on running Python app
body: <p>the full error is:</p>
  <pre><code>Windows fatal exception: access violation
  
  Current thread 0x0000160c (most recent call first):
  
    File &quot;E:\ml\projects\face swap\New folder\app.py&quot;, line 36 in &lt;module&gt;
    File &quot;C:\Users\USER\AppData\Local\Programs\Thonny\lib\site-packages\thonny\backend.py&quot;, line 1272 in _execute_prepared_user_code
    File &quot;C:\Users\USER\AppData\Local\Programs\Thonny\lib\site-packages\thonny\backend.py&quot;, line 1200 in wrapper
    File &quot;C:\Users\USER\AppData\Local\Programs\Thonny\lib\site-packages\thonny\backend.py&quot;, line 1213 in wrapper
    File &quot;C:\Users\USER\AppData\Local\Programs\Thonny\lib\site-packages\thonny\backend.py&quot;, line 1259 in execute_source
    File &quot;C:\Users\USER\AppData\Local\Programs\Thonny\lib\site-packages\thonny\backend.py&quot;, line 815 in _execute_source
    File &quot;C:\Users\USER\AppData\Local\Programs\Thonny\lib\site-packages\thonny\backend.py&quot;, line 801 in _execute_file
    File &quot;C:\Users\USER\AppData\Local\Programs\Thonny\lib\site-packages\thonny\backend.py&quot;, line 403 in _cmd_Run
    File &quot;C:\Users\USER\AppData\Local\Programs\Thonny\lib\site-packages\thonny\backend.py&quot;, line 204 in handle_command
    File &quot;C:\Users\USER\AppData\Local\Programs\Thonny\lib\site-packages\thonny\backend.py&quot;, line 146 in mainloop
    File &quot;C:\Users\USER\AppData\Local\Programs\Thonny\lib\site-packages\thonny\backend_launcher.py&quot;, line 87 in &lt;module&gt;
  Windows fatal exception: access violation
  
  </code></pre>
  <p>The Source code is:</p>
  <pre><code>import cv2
  # used for accessing url to download files
  import urllib.request as urlreq
  # used to access local directory
  import os
  # used to plot our images
  
  
  pic = &quot;dataset/face.jpg&quot;
  
  
  # read image with openCV
  image = cv2.imread(pic)
  
  # plot image with matplotlib package
  image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
  image_gray = cv2.cvtColor(image_rgb, cv2.COLOR_BGR2GRAY)
  
  haarcascade = &quot;dataset/cascade.xml&quot;
  detector = cv2.CascadeClassifier(haarcascade)
  faces = detector.detectMultiScale(image_gray)
  for face in faces:
  #     save the coordinates in x, y, w, d variables
      (x,y,w,d) = face
      # Draw a white coloured rectangle around each face using the face's coordinates
      # on the &quot;image_template&quot; with the thickness of 2 
      cv2.rectangle(image_rgb,(x,y),(x+w, y+d),(255, 255, 255), 2)
  #cv2.imshow('Image',image_rgb)
  #cv2.waitKey(0)
  #cv2.destoyAllWindows()
  
  LBFmodel = &quot;dataset/lbfmodel.yaml&quot;
  
  landmark_detector  = cv2.face.createFacemarkLBF()
  landmark_detector.loadModel(LBFmodel)
  _, landmarks = landmark_detector.fit(image_gray, faces)
  </code></pre>
  <p>It is a simple Face detector app in OpenCV but I wanter to add Facial landmark mark detection in this...
  everything works fine until I add the last three lines of code which crashes the whole app</p>
  <p>Also, I am using python 3.6.7 and purposefully downgraded the version of opencv to 3.4.6.</p>