我的问题是如何将药片集中在一起?
我试着周围添加中心街区,也改变float:left到float:center,但没有什么帮助.
我目前正在研究基于视频监控的入侵系统.为了完成这个任务,我拍摄了我的场景背景的快照(假设它完全干净,没有人或移动物体).然后,我比较从(静态)摄像机获得的帧并寻找差异.我必须能够检查任何差异,不仅是人的形状或其他什么,所以我不能具体提取特征.
通常,我有:
我正在使用OpenCV,所以要比较我基本上做的:
cv::Mat bg_frame;
cv::Mat cam_frame;
cv::Mat motion;
cv::absdiff(bg_frame, cam_frame, motion);
cv::threshold(motion, motion, 80, 255, cv::THRESH_BINARY);
cv::erode(motion, motion, cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3,3)));
Run Code Online (Sandbox Code Playgroud)
结果如下:
正如你所看到的那样,手臂被剥离了(由于我猜的颜色差异冲突),这很遗憾不是我想要的.
我想添加使用cv::Canny()以检测边缘并填充手臂的缺失部分,但遗憾的是(再一次),它只解决了少数情况下的问题,而不是大多数情况.
我可以使用任何算法或技术来获得准确的差异报告吗?
PS:对不起图片.由于我的新订阅,我没有足够的声誉.
编辑 我在这里使用灰度图像,但我对任何解决方案都持开放态度.
我需要一个Bash脚本,它将获得一个包含n个元素作为输入的数组,并返回该数组的powerset.
所以对于array=(a, b, c, d)输出应该是
a
ab
abc
abcd
abd
ac
acd
b
bc
bcd
c
cd
d
Run Code Online (Sandbox Code Playgroud)
请注意,任何元素都不应重复(aab,accd,abbc无效),并且abc与cba相同(顺序并不重要).
我找到的类似问题的每个解决方案都给出了固定长度(长度为2或3的组合)或允许重复(如aacd),甚至对于其他语言(不是我可以用其他语言做很多......)
我想出了这个:
string='a b c d'
read -a array <<< "$string"
count="${#array[@]}"
level=0
for (( level = 0; level < $count; level++ )); do
for (( i = $level; i < $count; i++ )); do
output+=" ${array[$i]}"
echo $output
done
output=''
done
Run Code Online (Sandbox Code Playgroud)
我的输出是
a
a b
a b c
a b c d
b
b c
b c d …Run Code Online (Sandbox Code Playgroud) 我正在使用Django.我有一个HTML页面,我在那里做一些Javascript的东西,然后我用这种方式做一个jQuery帖子:
$.ajax({
url: '/xenopatients/measurement/qual',
type: 'POST',
data: {'obj':data},
dataType: 'json',
contentType: "application/json; charset=utf-8", //questo ok
});
Run Code Online (Sandbox Code Playgroud)
在此帖子请求之后,我的Django视图正确处理了此URL的调用.我想要它做的是处理数据,将用户发送到另一页,并将此数据发送到新页面.问题是我不能像往常一样在Python中执行重定向,就像代码忽略重定向一样.
我的Python代码是:
@csrf_protect
@login_required#(login_url='/xenopatients/login/')
def qualMeasure(request):
name = request.user.username
print "enter"
if request.method == 'POST':
print request.POST
if "obj" in request.POST:
print 'obj received'
return render_to_response('mice/mice_status.html', RequestContext(request))
return render_to_response('measure/qual.html', {'name': name, 'form': QualMeasureForm()}, RequestContext(request))
Run Code Online (Sandbox Code Playgroud)
我发现更改页面的唯一方法是在上面的代码之后通过Javascript:
top.location.href = "/xenopatients/measurement";
Run Code Online (Sandbox Code Playgroud)
但是我不知道在使用这种方法时如何传递我需要的数据.
HTML代码:
<form action="" method="">
<table id="dataTable" width="100%" border="1"></table><br>
<script language="javascript">
document.measureForm.id_barcode.focus();
document.measureForm.Add.disabled = false;
$('#dataTable').tablePagination({});
</script>
<input type="button" name="save" value="Save Measure Serie" onclick="table2JSON('dataTable')"/>
</form>
Run Code Online (Sandbox Code Playgroud)
PS我也试过 …
我发现Express有一个应用程序生成器,但是文档没有解释每个目录和文件的用途.如果有人能给我一个简短的解释,说明我应该把哪些文件放在哪里,那将非常感激.这是生成的应用程序结构:
??? app.js
??? bin
? ??? www
??? package.json
??? public
? ??? images
? ??? javascripts
? ??? stylesheets
? ??? style.css
??? routes
? ??? index.js
? ??? users.js
??? views
??? error.jade
??? index.jade
??? layout.jade
7 directories, 9 files
Run Code Online (Sandbox Code Playgroud) 我试图创建一个程序,采取用户输入,而不是显示实际输入我想用*替换输入
我已经尝试使用此代码,但我不断收到下面的错误,我将不胜感激任何指导或帮助.
import msvcrt
import sys
def userinput(prompt='>'):
write = sys.stdout.write
for x in prompt:
msvcrt.putch(x)
entry = ""
while 1:
x = msvcrt.getch()
print(repr(x))
if x == '\r' or x == '\n':
break
if x == '\b':
entry = entry[:-1]
else:
write('*')
entry = entry + x
return entry
userEntry = userinput()
Run Code Online (Sandbox Code Playgroud)
错误:
Traceback (most recent call last):
File "C:\Users\Mehdi\Documents\Teaching\KS5\AS CS\getPass.py", line 24, in <module>
userEntry = userinput()
File "C:\Users\Mehdi\Documents\Teaching\KS5\AS CS\getPass.py", line 9, in userinput
msvcrt.putch(x)
TypeError: putch() argument …Run Code Online (Sandbox Code Playgroud) 我需要一些有关 Google API 数据数组创建的帮助。请参阅下面的详细信息:我有以下动态创建的数组。
schoolYear = [ 2014,2015,];
schoolReading = [420.5,520.5,];
schoolWriting = [436.5,536.5,];
schoolSpelling = [425.1,525.1,];
schoolNumeracy = [395.5,495.5,];
schoolGramPunc = [436,536,];
schoolTotAvg = [437,537,];
Run Code Online (Sandbox Code Playgroud)
我正在尝试像这样创建 google.visualization.arrayToDataTable:
for (i = 0; i < schoolTotAvg.length; i++) {
var data = google.visualization.arrayToDataTable([
['Year', 'Reading', 'Numeracy', 'Grammar/Punctuation', 'Writing', 'Spelling', 'Total Average'],
[schoolYear, schoolReading, schoolNumeracy, schoolGramPunc, schoolWriting, schoolSpelling, schoolTotAvg]
]);
}
Run Code Online (Sandbox Code Playgroud)
当我看到页面源时,我没有得到正确的数组。
有人可以帮忙吗?
--潘卡伊
我是python的初学者,可能会带来一些基本问题.有人可以帮忙吗?
我想得到每个学生的平均值,然后计算这些平均值的平均值.获取"TypeError:字符串索引必须是整数,而不是str".无法弄清楚它所指的是什么以及如何修改.这是我的代码:
lloyd = {
"name": "Lloyd",
"homework": [90.0, 97.0, 75.0, 92.0],
"quizzes": [88.0, 40.0, 94.0],
"tests": [75.0, 90.0]
}
alice = {
"name": "Alice",
"homework": [100.0, 92.0, 98.0, 100.0],
"quizzes": [82.0, 83.0, 91.0],
"tests": [89.0, 97.0]
}
tyler = {
"name": "Tyler",
"homework": [0.0, 87.0, 75.0, 22.0],
"quizzes": [0.0, 75.0, 78.0],
"tests": [100.0, 100.0]
}
def average(numbers):
total = sum(numbers)
total = float(total)
return total/len(numbers)
def get_average(student):
homework = average(student["homework"])
quizzes = average(student["quizzes"])
tests = average(student["tests"])
return 0.1*homework + …Run Code Online (Sandbox Code Playgroud) 我不明白这一点,它会困扰我直到我明白。
此 python 代码计算每个字符出现在 'message' 变量中的次数:
message = 'Some random string of words'
dictionary= {}
for character in message.upper():
dictionary.setdefault(character,0)
dictionary[character] = dictionary[character] + 1
print(dictionary)
Run Code Online (Sandbox Code Playgroud)
如果您多次运行它,您会注意到计数每次都以看似随机的顺序返回。为什么是这样?我认为循环应该每次都从字符串的开头开始,并以一致的顺序返回值……但事实并非如此。是否有随机性的一些元素在setdefault(),print()或upper()方法,这也影响着字符串处理的顺序?
我的 result.json 看起来像这样:
[
{
"id":"1",
"label":"2017-03-30",
"value":"1675000"
},
{
"id":"2",
"label":"2017-04-01",
"value":"1440000"
},
{
"id":"2",
"label":"2017-04-02",
"value":"830000"
},
]
Run Code Online (Sandbox Code Playgroud)
如何获取 json 数组中的特定项目。
例如我想为每个“值”输出如果
id=2 and label=2017-04-01
Run Code Online (Sandbox Code Playgroud) python ×3
ajax ×1
bash ×1
css ×1
dictionary ×1
difference ×1
django ×1
express ×1
html ×1
input ×1
javascript ×1
jquery ×1
json ×1
list ×1
node.js ×1
opencv ×1
permutation ×1
post ×1
redirect ×1