小编Nam*_*eja的帖子

OpenCV中的CascadeClassifier会生成错误

我正在尝试开发一个简单的应用程序来检测给定图像中的面部和眼睛:

from cv2 import *
face_cascade = CascadeClassifier('haarcascade_frontalface_default.xml')
eye_cascade = CascadeClassifier('haarcascade_eye.xml')

img = imread("123.jpg")
gray = cvtColor(img, COLOR_BGR2GRAY)
rows,cols = gray.shape
gray = getRotationMatrix2D((cols/2,rows/2),-90,1)

faces = face_cascade.detectMultiScale(gray, 1.3, 5, 0)
print faces

for (x,y,w,h) in faces:
    img = rectangle(img, (x,y), ((x+w),(x+h)), (255,0,0), 2)
    #gray = rectangle(gray, (x,y), ((x+w), (x+y)), (0, 255, 0), 4)
    roi_gray = gray[y:y+h, x:x+w]
    roi_color = img[y:y+h, x:x+w]
    eyes = eye_cascade.detectMultiScale(roi_grey)
    for (ex,ey, ew, eh) in eyes:
        roi_color = rectangle(roi_color, (x,y), ((x+w), (y+h)), (50, 50, 50), 3) …
Run Code Online (Sandbox Code Playgroud)

opencv python-2.7 cascade-classifier haar-classifier

4
推荐指数
1
解决办法
4637
查看次数

解析 BeautifulSoup 中 select 下的所有选项

我有一个 HTML,其中有多个选择标签和每个选择标签下的多个下拉选项我想解析每个选择下的所有选项并存储它们

这就是 html 的样子

<select name="primary_select">
    <option></option>
    <option></option>
</select>
<select name="secondary_select">
    <option></option>
    <option></option>
</select>
Run Code Online (Sandbox Code Playgroud)

这就是我的代码的样子

我在 python 中使用 beautifulsoup 和 mechanize

汤 = BeautifulSoup(response.get_data())

 subject_options = soup.findAll('select', attrs = {'name': 'primary_select'} ).findAll("option")
print subject_options
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

AttributeError: 'ResultSet' object has no attribute 'findAll'
Run Code Online (Sandbox Code Playgroud)

感谢您的帮助:)

python mechanize beautifulsoup web-scraping python-2.7

1
推荐指数
1
解决办法
8575
查看次数