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.