我是新的python,我的母语是C.我正在做一个代码在python监控系统触发运动使用OpenCV。我在Adrian Rosebrock的博客 pyimagesearch.com中编写了我的代码。最初的代码是为Raspiberry Pi开发的,并附有Pi Camera模块,现在我正在尝试适应我笔记本的摄像头。他为一个简单的运动检测代码编写了一个简单的教程,并且在我的电脑中运行得非常好。但是我对这个其他代码很困难。也许这是一个愚蠢的错误,但作为begginer我找不到这个问题的具体答案。Python错误:参数-c/- conf是必需的
此图像包含导致错误(第15行)的代码部分和屏幕左侧的项目结构。
Image of python project for surveillance。
类似的部分,记事的原始代码:
# import the necessary packages
from pyimagesearch.tempimage import TempImage
from dropbox.client import DropboxOAuth2FlowNoRedirect
from dropbox.client import DropboxClient
from picamera.array import PiRGBArray
from picamera import PiCamera
import argparse
import warnings
import datetime
import imutils
import json
import time
import cv2
# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-c", "--conf", required=True,
help="path to the JSON configuration file")
args = vars(ap.parse_args())
# filter warnings, load the configuration and initialize the Dropbox
# client
warnings.filterwarnings("ignore")
conf = json.load(open(args["conf"]))
client = None
到现在为止我只更改这些事情:
- 排除进口亲戚PI相机。
- 更改
camera = PiCamera()
通过camera = cv2.VideoCapture(0)
。这样我使用笔记本的摄像头。 排除:
camera.resolution = tuple(conf["resolution"]) camera.framerate = conf["fps"] rawCapture = PiRGBArray(camera, size=tuple(conf["resolution"]))
- 替代的行
for f in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
通过while True:
。 - 排除程序中的两行是
rawCapture.truncate(0)
。
可能还有更多的事情要修复,如果你现在请告诉我,但首先我想了解如何解决mensage错误。我在Windows 7中使用Python 2.7和OpenCV 3.1中的PyCharm。对不起,没有发布整个代码,但一旦这是我在网站上的第一个问题,我有0的声望,显然我可以发布2个链接。整个原始代码位于pyimagesearch.com。感谢您的时间!
感谢您的指示hpaulij。我正在执行PyCharm的代码。当我运行在win7 cmd下面的命令py py_surveillance.py --conf conf.json时,前面的错误消失。 – Oshio