栏目分类:
子分类:
返回
文库吧用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
文库吧 > IT > 软件开发 > 后端开发 > Python

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

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

基于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)

转载请注明:文章转载自 www.wk8.com.cn
本文地址:https://www.wk8.com.cn/it/1037941.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 wk8.com.cn

ICP备案号:晋ICP备2021003244-6号