0

To give some background on the problem I am trying to deploy my django project to a microsoft azure server. My django project is mainly dealing with executing opencv functions. I made sure to test that all my opencv functions worked on my local host which they do but the main problem I'm having is getting them to work on an azure server. Everytime I try to call any opencv function I get the error:The matrix has NULL data pointer in function cvGetMat in my opencv function. I have tried googling the problem and have narrowed it down to my frame variable inside my function that is causing the problem. The stack trace has pointed out that the function keeps failing at this line: cv2.imshow('frame',gray). The full function is just a basic opencv function to play a video. The code is below:

def PlayVideo(request):
   filename="app/media/traffic.mp4"
   cap = cv2.VideoCapture(filename)




   while(cap.isOpened()):
      ret, frame = cap.read()


      gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

      cv2.imshow('frame',gray)
        if cv2.waitKey(1) & 0xFF == ord('q'):
             break

      cap.release()
      cv2.destroyAllWindows()

   return render_to_response('app/Configuration.html')

When I first encountered this problem I thought it may have been that it could not find the video file but I've modified the code with different paths that would not lead to a video but those don't even execute they just redirect back to the same page so I know that is not the problem. The stack trace shows the 'frame' array has values along with the 'gray' array which also has values. The stack trace is as follows:

I also have MEDIA_ROOT and MEDIA_URL defined in my settings.py along with a url in my urls.py to serve media files:

    url(r'^media/(?P<path>.*)$', django.views.static.serve, {
        'document_root': settings.MEDIA_ROOT,
    })

So to sum it all up my main question is how do I solve the error: The matrix has NULL data pointer in function cvGetMat in my opencv function in order to get my opencv function working on my azure server?

If any more information is required to come up with a reason as to why its failing and a solution feel free to let me know.

Peter Pan
  • 23,476
  • 4
  • 25
  • 43
user3354383
  • 47
  • 1
  • 1
  • 9
  • How big is the MP4 file? – Andrey Shipilov Apr 27 '17 at 08:59
  • the mp4 file is 16.3 MB – user3354383 Apr 27 '17 at 16:49
  • Which Azure service did you deploy it on? Web Apps/App Service or Cloud Service or Azure VM? – Peter Pan May 01 '17 at 09:10
  • If deploy on WebApps/App Service, I think you could not use some functions which be depended on some dynamic libraries like GDI, because there are some restrictions on App Service that you can refer to [here](https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#win32ksys-user32gdi32-restrictions) to know it. – Peter Pan May 01 '17 at 09:15
  • If deployed on Cloud Service, you can refer to the similar SO thread http://stackoverflow.com/questions/9354046/how-do-i-install-opencv-on-windows-azure to get some helps. Any concern or update? – Peter Pan May 01 '17 at 09:18

0 Answers0