• 基于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)
    
    • 1
    • 2
    • 3
    • 4

    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))
    
    • 1

    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)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    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)
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

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

  • 相关阅读:
    通过openssl库计算字符串或文件sha256
    仿真测试断开服务器公网连接
    vue3.2学习笔记
    sql 时间函数
    如何通过A/B测试提升Push推送消息点击率?
    R可视化:剂量反应曲线图
    韩顺平linux学习(18-31)
    Electron-builder打包和自动更新
    【7. 进程管理】
    2013年-2018年上市公司审计数据
  • 原文地址:https://blog.csdn.net/weixin_50862344/article/details/126237789