text stringlengths 1 93.6k |
|---|
raise IOError("Couldn't open webcam or video")
|
video_FourCC = int(vid.get(cv2.CAP_PROP_FOURCC))
|
video_fps = vid.get(cv2.CAP_PROP_FPS)
|
video_size = (int(vid.get(cv2.CAP_PROP_FRAME_WIDTH)),
|
int(vid.get(cv2.CAP_PROP_FRAME_HEIGHT)))
|
isOutput = True if output_path != "" else False
|
if isOutput:
|
print("!!! TYPE:", type(output_path), type(video_FourCC), type(video_fps), type(video_size))
|
out = cv2.VideoWriter(output_path, video_FourCC, video_fps, video_size)
|
accum_time = 0
|
curr_fps = 0
|
fps = "FPS: ??"
|
prev_time = timer()
|
while True:
|
return_value, frame = vid.read()
|
image = Image.fromarray(frame)
|
image = yolo.detect_image(image)
|
result = np.asarray(image)
|
curr_time = timer()
|
exec_time = curr_time - prev_time
|
prev_time = curr_time
|
accum_time = accum_time + exec_time
|
curr_fps = curr_fps + 1
|
if accum_time > 1:
|
accum_time = accum_time - 1
|
fps = "FPS: " + str(curr_fps)
|
curr_fps = 0
|
cv2.putText(result, text=fps, org=(3, 15), fontFace=cv2.FONT_HERSHEY_SIMPLEX,
|
fontScale=0.50, color=(255, 0, 0), thickness=2)
|
cv2.namedWindow("result", cv2.WINDOW_NORMAL)
|
cv2.imshow("result", result)
|
if isOutput:
|
out.write(result)
|
if cv2.waitKey(1) & 0xFF == ord('q'):
|
break
|
yolo.close_session()
|
# <FILESEP>
|
import time
|
import xlrd
|
from selenium import webdriver
|
from selenium.webdriver.common.keys import Keys
|
import os
|
import requests
|
import json
|
import excelSave as save
|
# 用来控制页面滚动
|
def Transfer_Clicks(browser):
|
time.sleep(5)
|
try:
|
browser.execute_script("window.scrollBy(0,document.body.scrollHeight)", "")
|
except:
|
pass
|
return "Transfer successfully \n"
|
#判断页面是否加载出来
|
def isPresent():
|
temp =1
|
try:
|
driver.find_elements_by_css_selector('div.line-around.layout-box.mod-pagination > a:nth-child(2) > div > select > option')
|
except:
|
temp =0
|
return temp
|
#插入数据
|
def insert_data(elems,path,name,yuedu,taolun,num,save_pic):
|
for elem in elems:
|
workbook = xlrd.open_workbook(path) # 打开工作簿
|
sheets = workbook.sheet_names() # 获取工作簿中的所有表格
|
worksheet = workbook.sheet_by_name(sheets[0]) # 获取工作簿中所有表格中的的第一个表格
|
rows_old = worksheet.nrows # 获取表格中已存在的数据的行数
|
rid = rows_old
|
#用户名
|
weibo_username = elem.find_elements_by_css_selector('h3.m-text-cut')[0].text
|
weibo_userlevel = "普通用户"
|
#微博等级
|
try:
|
weibo_userlevel_color_class = elem.find_elements_by_css_selector("i.m-icon")[0].get_attribute("class").replace("m-icon ","")
|
if weibo_userlevel_color_class == "m-icon-yellowv":
|
weibo_userlevel = "黄v"
|
if weibo_userlevel_color_class == "m-icon-bluev":
|
weibo_userlevel = "蓝v"
|
if weibo_userlevel_color_class == "m-icon-goldv-static":
|
weibo_userlevel = "金v"
|
if weibo_userlevel_color_class == "m-icon-club":
|
weibo_userlevel = "微博达人"
|
except:
|
weibo_userlevel = "普通用户"
|
#微博内容
|
#点击“全文”,获取完整的微博文字内容
|
weibo_content = get_all_text(elem)
|
#获取微博图片
|
if save_pic:
|
num = get_pic(elem,num)
|
#获取分享数,评论数和点赞数
|
shares = elem.find_elements_by_css_selector('i.m-font.m-font-forward + h4')[0].text
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.