人工智能算法遇到的问题及解决方法

1.cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv\modules\imgproc\src\resize.cpp:4044: error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'
解决:图片的路径格式错误,由‘\’改为‘/’即可。

2.ValueError: shapes (1,10) and (2500,1) not aligned: 10 (dim 1) != 2500 (dim 0)

解决:

LBP人脸识别算法学习心得

因为找了太多程序最终还是没调试成功,决定分块自己写

首先是裁剪图片

#将图片改为同一个大小(50*50)
from PIL import Image
import os.path
import glob
def convertjpg(jpgfile, outdir, width=50, height=50):
    img = Image.open(jpgfile)
    try:
        new_img = img.resize((width, height), Image.BILINEAR)
        if not os.path.exists(outdir):
            os.mkdir(outdir)
        new_img.save(os.path.join(outdir, os.path.basename(jpgfile)))
    except Exception as e:
        print(e)
path = r"F:\daima\singleji\*.jpg" #原始图片的存储路径
for jpgfile in glob.glob(path):
    convertjpg(jpgfile, r"F:\daima\jieguo") #生成图片的存储路径

将图片转为灰度图

#将图像转为灰度图
path = 'F:\daima\jieguo'
file_list = os.listdir(path)
for file in file_list:
    I = Image.open(path+"/"+file)
    L = I.convert('L')
    L.save(path+"/"+file)
    #print(file)
equalizeHist  函数用来直方图均衡化,以提高图像的质量

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值