One Spot Detection

 1. Code


'''
python One_Spot_Detection.py picture -i 6YuRF.png
python One_Spot_Detection.py camera -c
'''

import cv2
import argparse
import numpy as np

def CVShow(img, title = None, max_h = 950, max_w = 1800):
    img = np.array(img)
    cv2.namedWindow(title, cv2.WINDOW_KEEPRATIO)
    H,W = img.shape[0],img.shape[1]
    if H > max_h:
        ratio = max_h / H
        H, W = int(ratio * H), int(ratio * W)
    if W > max_w :
        ratio = max_w / W
        H, W = int(ratio * H), int(ratio * W)
    cv2.resizeWindow(title, W, H)
    cv2.imshow(title, img)
    key = cv2.waitKey(0)
    if key == ord('s'):  # wait for key to write or exit
        if title == None:title = 'unNamed'
        cv2.imwrite(title+'.jpg', img)
    cv2.destroyAllWindows()

def SingleImageProcessing(args):
    frame = cv2.imread(args.image)
    circleRadius, colorRed = 41, (255, 0, 0)
    grayFrame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    blurFrame = cv2.GaussianBlur(grayFrame, (circleRadius, circleRadius), 0) # Image blurring.
    minValue, maxValue, minLocation, maxLocation = cv2.minMaxLoc(blurFrame) # get the brightest pixel in the frame.
    cv2.circle(frame, maxLocation, circleRadius, colorRed, 2) # draw circle around the pixel.
    CVShow(frame, "frame")

def RealTimeVideoProcessing(args):
    # 调取摄像头实时监测
    cap = cv2.VideoCapture(0)
    circleRadius = 41
    colorRed = (255, 0, 0)
    while True:
        _, frame = cap.read()
        grayFrame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # Image blurring.
        blurFrame = cv2.GaussianBlur(grayFrame, (circleRadius, circleRadius), 0) # get the brightest pixel in the frame.
        (minValue, maxValue, minLocation, maxLocation) = cv2.minMaxLoc(blurFrame) # draw circle around the pixel.
        cv2.circle(frame, maxLocation, circleRadius, colorRed, 2)
        cv2.imshow("frame", frame)
        key = cv2.waitKey(1)
        if key == 27:
            break
    cap.release()
    cv2.destroyAllWindows()

def initiate():
    parser = argparse.ArgumentParser(description="Brightest spot detection")
    subparser = parser.add_subparsers()

    picture = subparser.add_parser('picture', help='Single picture processing')
    picture.add_argument('-i', '--image', type=str, required=True, help='image path')
    picture.set_defaults(func=SingleImageProcessing)

    camera = subparser.add_parser('camera', help='Real time monitoring video processing')
    camera.add_argument('-c', '--camera', action='store_true', help='Activate real time monitoring video processing')
    camera.set_defaults(func=RealTimeVideoProcessing)

    args = parser.parse_args()
    args.func(args)

if __name__ == '__main__':
    initiate()

2. Reference

GitHub Link

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Spotfire是一种用于数据可视化和分析的软件平台。要学习Spotfire的使用,可以按照以下步骤进行: 1. 首先,需要将Spotfire客户端软件包部署到Spotfire服务器。这可以通过找到Spotfire.Dxp.sdn分发文件并将其部署到服务器来完成[1]。 2. 接下来,需要进行一些准备工作。首先,下载并解压Spotfire软件包。然后,配置SQL Server数据库的基础信息[2]。 3. 安装Spotfire服务器并进行初始化配置。在安装过程中,需要创建管理员账号。然后,将客户端软件包部署到Spotfire服务器[2]。 4. 启动Spotfire服务。 5. 进行用户认证,可以使用LDAP进行认证。 6. 安装节点管理器。 7. 安装Spotfire Analyst,这是Spotfire的客户端软件,用于进行数据分析和可视化。 8. 设置连接器,以便与其他数据源进行连接。 此外,如果你想在Spotfire中创建一个基于需求开发的组件,你可以使用HTML和JavaScript语言来制作一个静态图表。首先,你需要手动填充数据并生成一个组件的基础模板。然后,将这些代码嵌入到Spotfire中。在Spotfire中,你需要解决坐标轴的问题,使坐标轴刻度大小随数据大小改变,并将数据填充到左右两个坐标轴上。你还需要设置参数,将数据改为Spotfire数据表中的数据,并进行逻辑判断和数据接口的对接。Spotfire的代码可以使用Python语言框架进行处理[3]。 希望这些信息对你有帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值