I use opencv-python in django, but when I use cv2.imread , it just returns nonetype . How can I solve this problem?
from rest_framework.response import Response
from rest_framework.views import APIView
from rest_framework import status
from . import serializers
from .serializers import call_serializers
from .apps import BmiEstimationConfig
import pickle
from skimage import io
class BMIEstimationView(APIView):
serializer_class = serializers.call_serializers
def post(self, request):
serializer = serializers.call_serializers(data=request.data)
serializer.is_valid(raise_exception=True)
file = request.FILES['file']
import cv2
image = cv2.imread(file)
print(image)```
got this :
> TypeError: bad argument type for built-in operation
Please make sure the syntax of the cv2.imread()
Syntax: cv2.imread(path, flag)
Parameters:
path: A string representing the path of the image to be read.
flag: It specifies the way in which image should be read. It’s default value is cv2.IMREAD_COLOR
Return Value: This method returns an image that is loaded from the specified file.
and also please provide full path of your image
to see the examples click here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.