- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在从屏幕上移动的 block 的中心访问存储的 x、y 坐标列表时遇到了一些问题。我已经能够成功获取每一帧的 block 的 x 和 y 坐标,但在存储此信息然后无法在某些阶段访问该点时遇到问题。我的目标是能够将这些点连接在一起形成一条轨迹。低于我目前拥有的。
类定义:
class People:
def __init__(self):
self.x = 0
self.y = 0
假设在检测到中心的每个点,cX 和 cY 都正确更新。
MultPeople=[]
以下内容属于逐帧遍历视频的循环
Person=People()
Person.x=cX
Person.y=cY
MultPeople.append(Person)
但现在当我想按顺序访问这些点以连接点时,我一次只能得到一个点,因此我无法做到。
for index,man in enumerate(MultPeople):
print (index,man.x,man.y)
xplot=man.x
yplot=man.y
cv2.circle(frame1, (xplot, yplot), 2, [50, 20, 255], 3)
这样就成功在原图的中心点画了一个圆,但是答案是这样返回的
(0, 306, 379)
(0, 307, 377)
(0, 307, 384)
(0, 305, 396)
(0, 309, 409)
(0, 310, 431)
为了获得索引的值需要添加什么,我假设这是为了访问某些点所需要的。
我也是在打印index,man.x,man.y后输入了下面这行
print np.size(MultPeople)
它每次都打印回 1,因此我认为问题出在 append 函数上,因为它不是每次都向列表中添加新值,但我不确定应该如何更正。
最佳答案
将更新循环中的所有代码“按原样”不间断地发布到打印循环中,因为很难看到这样的问题。但据我所知——您可能在更新循环中创建、更新和打印了列表,如下所示:
while condition:
MultPeople=[]
Person=People()
# Here you somehow get the new cX and cY values
Person.x=cX
Person.y=cY
MultPeople.append(Person)
for index,man in enumerate(MultPeople):
print (index,man.x,man.y)
xplot=man.x
yplot=man.y
cv2.circle(frame1, (xplot, yplot), 2, [50, 20, 255], 3)
因此列表 MultPeople
被创建, append 了一项,然后 for
循环遍历列表中的一项(即它只执行一次,使用 index == 0
and size
of 1
) 然后你会收到你的结果。
也就是说,如果我的猜测是正确的。您真的应该按原样发布代码,将它切成碎片阅读真的很难。
如果是这种情况,您真正想要的是:
MultPeople=[]
while condition:
Person=People()
# Here you somehow get the new cX and cY values
Person.x=cX
Person.y=cY
MultPeople.append(Person)
for index,man in enumerate(MultPeople):
print (index,man.x,man.y)
xplot=man.x
yplot=man.y
cv2.circle(frame1, (xplot, yplot), 2, [50, 20, 255], 3)
关于python - 从移动对象中获取的点列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38010161/
我的一位教授给了我们一些考试练习题,其中一个问题类似于下面(伪代码): a.setColor(blue); b.setColor(red); a = b; b.setColor(purple); b
我似乎经常使用这个测试 if( object && object !== "null" && object !== "undefined" ){ doSomething(); } 在对象上,我
C# Object/object 是值类型还是引用类型? 我检查过它们可以保留引用,但是这个引用不能用于更改对象。 using System; class MyClass { public s
我在通过 AJAX 发送 json 时遇到问题。 var data = [{"name": "Will", "surname": "Smith", "age": "40"},{"name": "Wil
当我尝试访问我的 View 中的对象 {{result}} 时(我从 Express js 服务器发送该对象),它只显示 [object][object]有谁知道如何获取 JSON 格式的值吗? 这是
我有不同类型的数据(可能是字符串、整数......)。这是一个简单的例子: public static void main(String[] args) { before("one"); }
嗨,我是 json 和 javascript 的新手。 我在这个网站找到了使用json数据作为表格的方法。 我很好奇为什么当我尝试使用 json 数据作为表时,我得到 [Object,Object]
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
我听别人说 null == object 比 object == null check 例如: void m1(Object obj ) { if(null == obj) // Is thi
Match 对象 提供了对正则表达式匹配的只读属性的访问。 说明 Match 对象只能通过 RegExp 对象的 Execute 方法来创建,该方法实际上返回了 Match 对象的集合。所有的
Class 对象 使用 Class 语句创建的对象。提供了对类的各种事件的访问。 说明 不允许显式地将一个变量声明为 Class 类型。在 VBScript 的上下文中,“类对象”一词指的是用
Folder 对象 提供对文件夹所有属性的访问。 说明 以下代码举例说明如何获得 Folder 对象并查看它的属性: Function ShowDateCreated(f
File 对象 提供对文件的所有属性的访问。 说明 以下代码举例说明如何获得一个 File 对象并查看它的属性: Function ShowDateCreated(fil
Drive 对象 提供对磁盘驱动器或网络共享的属性的访问。 说明 以下代码举例说明如何使用 Drive 对象访问驱动器的属性: Function ShowFreeSpac
FileSystemObject 对象 提供对计算机文件系统的访问。 说明 以下代码举例说明如何使用 FileSystemObject 对象返回一个 TextStream 对象,此对象可以被读
我是 javascript OOP 的新手,我认为这是一个相对基本的问题,但我无法通过搜索网络找到任何帮助。我是否遗漏了什么,或者我只是以错误的方式解决了这个问题? 这是我的示例代码: functio
我可以很容易地创造出很多不同的对象。例如像这样: var myObject = { myFunction: function () { return ""; } };
function Person(fname, lname) { this.fname = fname, this.lname = lname, this.getName = function()
任何人都可以向我解释为什么下面的代码给出 (object, Object) 吗? (console.log(dope) 给出了它应该的内容,但在 JSON.stringify 和 JSON.parse
我正在尝试完成散点图 exercise来自免费代码营。然而,我现在只自己学习了 d3 几个小时,在遵循 lynda.com 的教程后,我一直在尝试确定如何在工具提示中显示特定数据。 This code
我是一名优秀的程序员,十分优秀!