Django.fun

<built-in function imread> returned NULL without setting an error in django views

i want to create a qr scanner in django.for that i have a model with a field call "image" and a form
views.py:

@login_required
def scan_qr(request):
    if request.method == 'POST':
        form = QrScannerForm(request.POST,request.FILES)
        if form.is_valid():
            scanner = form.save(commit=False)
            scanner.save()
            image = scanner.image
            print(scanner)
            print(image)
            img=cv2.imread(image)

            det=cv2.QRCodeDetector()
            val, pts, st_code=det.detectAndDecode(img)
            print(val)
            return HttpResponseRedirect(val)

    else:
        form = QrScannerForm()
        return render(request,'profile/scan_qr.html',{'form':form})

i am getting the image but the line is not working "img=cv2.imread(image)" it is throwing error " returned NULL without setting an error" how can i fix this ?

Answers: 0