小编tes*_*ter的帖子

我如何使用带有图像单应性的Orb探测器?

我想使用orb探测器在找到的图像周围绘制一个边界框,类似于这里使用筛选探测器的示例:SIFT Refrence

Linked示例使用FlannBasedMatcher.我的代码使用BFMatcher.我在使用的Matcher中没有偏好.

        MIN_MATCH_COUNT = 10

        img1 = cv2.imread('box.png',0)
        img2 = cv2.imread('box_in_scene.png',0)

        orb = cv2.ORB_create()

        kp1, des1 = orb.detectAndCompute(img1,None)
        kp2, des2 = orb.detectAndCompute(img2,None)

        bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
        matches = bf.match(des1,des2)
Run Code Online (Sandbox Code Playgroud)

我将如何继续使用单应性来绘制box_in_scene图像?

编辑:我尝试了以下,但输出不是预期的.

src_pts = np.float32([ kp1[m.queryIdx].pt for m in matches[:50] ]).reshape(-1,1,2)
dst_pts = np.float32([ kp2[m.trainIdx].pt for m in matches[:50] ]).reshape(-1,1,2)
M, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC,5.0)
matchesMask = mask.ravel().tolist()
h,w = img1.shape
pts = np.float32([ [0,0],[0,h-1],[w-1,h-1],[w-1,0] ]).reshape(-1,1,2)
dst = cv2.perspectiveTransform(pts,M)
Run Code Online (Sandbox Code Playgroud)

python opencv object-detection homography orb

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

Python:列表中的UUID

我有一个包含 uuid4 的列表。我也有一个字符串。例如:

list = [UUID('79d8f4b7-06a0-41d1-99d6-dd8c5308875f'), 'example1', 'example2']
string = 79d8f4b7-06a0-41d1-99d6-dd8c5308875f
Run Code Online (Sandbox Code Playgroud)

但是当我尝试:

if string in list:
    print("It's in!")
else:
    print("It's not!")
Run Code Online (Sandbox Code Playgroud)

输出总是“它不是”。

我知道可能存在数据类型错误,但我自己似乎找不到。任何帮助表示赞赏,我相信这个简单的事情会在几秒钟内得到修复,提前致谢。

当我输入 print list[0] 时,这是输出:79d8f4b7-06a0-41d1-99d6-dd8c5308875f。但即使我尝试说“..in list[0]”,它仍然不起作用。

python uuid compare list

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

Python Tkinter Treeview - 迭代'get_children'输出

我想稍后迭代Treeview中的数据.然后我希望能够对它进行整理.

from tkinter import *
from tkinter.ttk import *
import pickle

root = Tk()

def treeData(event):
    children = tree.get_children()
    print(children)

entry = StringVar()
a = Entry(root, textvariable=entry)
a.grid(column=0,row=0)
a.bind("<Key>", function)

file_data = []
file = open('data.dat', 'rb')
while True:
    try:
        file_data.append(pickle.load(file))
    except EOFError:
        break
file.close()

column_names = ("Column 1", "Column 2")
tree = Treeview(root, columns=column_names)
tree['show'] = 'headings'
for x in file_data:
    a = tree.insert('', 'end', values=x)
for col in column_names: 
    tree.heading(col, text=col)

tree.grid(column=0, row=1)
Run Code Online (Sandbox Code Playgroud)

在我打印(子)时称为'treeData'的函数中,它输出一个类似于此的列表 - ('I001','I002','I003','I004')

我希望有人知道如何将这些数据转换成实际显示在Treeview行中的内容?

谢谢,

python treeview children tkinter

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

C - 排序时如何不更改int数组的值

我是C编程的新手,想知道是否有办法防止更改数组的值.

我有一个数组:

int *array = makeArray();
Run Code Online (Sandbox Code Playgroud)

然后我对这个数组应用一个排序方法:

sortingMethod1(array);
Run Code Online (Sandbox Code Playgroud)

我打电话的时候:

sortingMethod2(array);
Run Code Online (Sandbox Code Playgroud)

该列表已经排序,我无法对第二种排序方法进行基准测试.

我想知道是否有一种方法可以将相同的数组传递给两个函数,而无需为下一个函数排序.

如果有人能帮我解决一个非常简单的问题,我会很感激.

c arrays

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

标签 统计

python ×3

arrays ×1

c ×1

children ×1

compare ×1

homography ×1

list ×1

object-detection ×1

opencv ×1

orb ×1

tkinter ×1

treeview ×1

uuid ×1