% 获取运动目标模板 template = gray_frame(min_row:max_row, min_col:max_col); % 缩小模板 resized_template = imresize(template, 0.5);min_row:max_row, min_col:max_col怎么获得
时间: 2023-12-02 07:06:40 浏览: 36
这里的 `min_row`, `max_row`, `min_col`, `max_col` 可以通过目标物体的位置信息获得。假设你使用了一个物体检测器来检测运动物体,那么物体检测器会返回物体的位置信息,包括物体在图像中的左上角和右下角坐标 `(x1, y1)` 和 `(x2, y2)`。那么你就可以将目标物体的位置信息转换成 `min_row`, `max_row`, `min_col`, `max_col`,如下所示:
```
min_row = y1;
max_row = y2;
min_col = x1;
max_col = x2;
```
这样就可以根据物体的位置信息获取到目标物体的模板了。当然,这里的 `gray_frame` 可以是视频帧的灰度图像,也可以是彩色图像的某个通道的灰度图像。
相关问题
if __name__ == "__main__":pycharm里面有没有创建这个的快捷键
在 PyCharm 中,你可以使用以下步骤创建一个名为 `ifmain` 的模板:
1. 点击菜单栏的 "File" -> "Settings",打开设置窗口。
2. 在设置窗口中,选择 "Editor" -> "Live Templates"。
3. 点击 "+" 图标,创建一个新的模板。
4. 在 "Abbreviation" 文本框中输入 `ifmain`。
5. 在 "Template text" 文本框中输入以下代码:
```python
if __name__ == "__main__":
$END$
```
6. 点击 "Apply" 和 "OK" 按钮保存模板。
现在你可以在 PyCharm 中输入 `ifmain` 并按下 Tab 键,PyCharm 将自动插入上面的模板。
請你幫我檢from flask import Flask, render_template, request, redirect import openpyxl app = Flask(__name__) # 首页,录入数据页面 @app.route('/', methods=['GET', 'POST']) def index(): if request.method == 'POST': # 从表单中获取数据 confirm_date = request.form['confirm_date'] shift = request.form['shift'] machine_model = request.form['machine_model'] issue = request.form['issue'] issue_qty = request.form['issue_qty'] note = request.form['note'] # 打开Excel文件并写入数据 wb = openpyxl.load_workbook('D:/data.xlsx') ws = wb.active row_count = ws.max_row ws.cell(row=row_count+1, column=1, value=confirm_date) ws.cell(row=row_count+1, column=2, value=shift) ws.cell(row=row_count+1, column=3, value=machine_model) ws.cell(row=row_count+1, column=4, value=issue) ws.cell(row=row_count+1, column=5, value=int(issue_qty)) ws.cell(row=row_count+1, column=6, value=note) wb.save('D:/data.xlsx') return redirect('/') else: return render_template('index.html') # 查询记录页面 @app.route('/search_record', methods=['GET', 'POST']) def search_record(): if request.method == 'POST': # 从表单中获取查询条件 start_date = request.form['start_date'] end_date = request.form['end_date'] machine_model = request.form['machine_model'] # 打开Excel文件并查询数据 wb = openpyxl.load_workbook('D:/data.xlsx') ws = wb.active data = [] for row in ws.iter_rows(min_row=2): if start_date <= str(row[0].value) <= end_date: if row[2].value == machine_model or machine_model == '全部': data.append([row[0].value, row[1].value, row[2].value, row[3].value, row[4].value, row[5].value]) return render_template('search_record.html', data=data) else: return render_template('search_record.html') if __name__ == '__main__': app.run(debug=True,host="0.0.0.0")
这段代码看起来没有语法错误,但需要确保您已经正确安装了 Flask 和 openpyxl 库。此外,需要确保您的 Excel 文件 'D:/data.xlsx' 存在并且可写。在使用 openpyxl 时,建议您使用上下文管理器来打开并保存文件,这可以确保在使用文件后正确关闭文件。下面是更新后的代码:
```
from flask import Flask, render_template, request, redirect
import openpyxl
app = Flask(__name__)
# 首页,录入数据页面
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
# 从表单中获取数据
confirm_date = request.form['confirm_date']
shift = request.form['shift']
machine_model = request.form['machine_model']
issue = request.form['issue']
issue_qty = request.form['issue_qty']
note = request.form['note']
# 打开Excel文件并写入数据
with openpyxl.load_workbook('D:/data.xlsx') as wb:
ws = wb.active
row_count = ws.max_row
ws.cell(row=row_count+1, column=1, value=confirm_date)
ws.cell(row=row_count+1, column=2, value=shift)
ws.cell(row=row_count+1, column=3, value=machine_model)
ws.cell(row=row_count+1, column=4, value=issue)
ws.cell(row=row_count+1, column=5, value=int(issue_qty))
ws.cell(row=row_count+1, column=6, value=note)
wb.save('D:/data.xlsx')
return redirect('/')
else:
return render_template('index.html')
# 查询记录页面
@app.route('/search_record', methods=['GET', 'POST'])
def search_record():
if request.method == 'POST':
# 从表单中获取查询条件
start_date = request.form['start_date']
end_date = request.form['end_date']
machine_model = request.form['machine_model']
# 打开Excel文件并查询数据
with openpyxl.load_workbook('D:/data.xlsx') as wb:
ws = wb.active
data = []
for row in ws.iter_rows(min_row=2):
if start_date <= str(row[0].value) <= end_date:
if row[2].value == machine_model or machine_model == '全部':
data.append([row[0].value, row[1].value, row[2].value, row[3].value, row[4].value, row[5].value])
return render_template('search_record.html', data=data)
else:
return render_template('search_record.html')
if __name__ == '__main__':
app.run(debug=True, host="0.0.0.0")
```
注意:在生产环境中,不建议使用 Flask 的调试模式。如果您要在生产环境中运行应用程序,请将 `debug=True` 更改为 `debug=False`。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)