基于opencv的实时停车地点查找

基于opencv的实时停车地点查找的github
有点感觉这个已经被玩烂了也是这个主题的东东

CNN_model_for_occupancy.ipynb

整体思路

这份代码的整体思路也是opencv进行深度学习的一般思路

  1. Load Test and Train Files
  2. Set key parameters(常规内容没什么好细讲了)
  3. Build model on top of a trained VGG建立相应的模型(这里是vgg)

Load Test and Train Files模块

folder = 'train_data/train'
for sub_folder in os.listdir(folder):
    path, dirs, files = next(os.walk(os.path.join(folder,sub_folder)))
    files_train += len(files)

os.walk(path)含有例子的深度解析一句话就是:从给定的path走到底

那么为什么要用next?
其实如果你看了超链接里的就会发现os.walk是会分开几次遍历每一个文件夹,next应该就起到了连接不同文件夹的作用,从而得到全部的路径,文件夹和文件

Build model on top of a trained VGG

model = applications.VGG16(weights = "imagenet", include_top=False, input_shape = (img_width, img_height, 3))

include_top=False一般默认为True,Flase代表没有全连接层

x = model.output
x = Flatten()(x)
# x = Dense(512, activation="relu")(x)
# x = Dropout(0.5)(x)
# x = Dense(256, activation="relu")(x)
# x = Dropout(0.5)(x)
predictions = Dense(num_classes, activation="softmax")(x)

Dense其实可以理解成pytorch的linear层

至于ImageDataGenerator 类看这篇应该够用了

identify_parking_spots.ipynb

github上这个是失效了所以我还是学习的之前提到的

删掉不需要的地方:

#删掉不需要的地方
def filter_region(image, vertices):
    mask = np.zeros_like(image)
    if len(mask.shape) == 2:
        cv2.fillPoly(mask, vertices, 255)  # 多边形填充
        show('mask', mask)
    return cv2.bitwise_and(image, mask)

需要的地方用的是255填充,不需要的使用np.zeros_like(image),最后取并集bitwise_and(image, mask)

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值