Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

462
Views
How do I solve the error: error: (-27) The matrix has NULL data pointer in function cvGetMat in my opencv function?

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.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!