簡體   English   中英

為什么使用 django python 時 cv2.imread 不返回任何結果?

[英]Why cv2.imread returns none when using django python?

我在 django 中使用 opencv-python,但是當我使用cv2.imread時,它只返回nonetype 我怎么解決這個問題?

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

請確保 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.

並請提供您的圖像的完整路徑

查看示例 點擊這里

示例圖片: 在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM