我最近开始使用pylibfreenect2在Linux上使用Kinect V2.
当我第一次能够在散点图中显示深度帧数据时,我很失望地看到没有任何深度像素似乎在正确的位置.
我做了一些研究,并意识到有一些简单的触发来完成转换.
为了测试,我开始使用pylibfreenect2中的预编写函数,该函数接受列,行和深度像素强度,然后返回该像素的实际位置:
X, Y, Z = registration.getPointXYZ(undistorted, row, col)
Run Code Online (Sandbox Code Playgroud)
使用getPointXYZ()或getPointXYZRGB()的唯一缺点是它们一次只能处理一个像素.这在Python中可能需要一段时间,因为它需要使用嵌套的for循环,如下所示:
n_rows = d.shape[0]
n_columns = d.shape[1]
out = np.zeros((n_rows * n_columns, 3), dtype=np.float64)
for row in range(n_rows):
for col in range(n_columns):
X, Y, Z = registration.getPointXYZ(undistorted, row, col)
out[row * n_columns + col] = np.array([Z, X, -Y])
Run Code Online (Sandbox Code Playgroud)
我试图更好地理解getPointXYZ()如何计算坐标.据我所知,它看起来类似于OpenKinect for Forfor函数:depthToPointCloudPos().虽然我怀疑libfreenect2的版本还有更多内容.
使用该gitHub源代码作为示例,然后我尝试在Python中重新编写它以进行我自己的实验,并出现以下内容:
#camera information based on the Kinect v2 hardware
CameraParams = {
"cx":254.878,
"cy":205.395,
"fx":365.456,
"fy":365.456,
"k1":0.0905474, …Run Code Online (Sandbox Code Playgroud) 我希望django rest在序列化时不将我的DateTime模型字段转换为字符串日期表示.
response_date = serializers.DateTimeField(source="updated_at")
Run Code Online (Sandbox Code Playgroud)
我希望这个出来
1411880508
并不是
"2014-09-28T05:01:48.123"
我花了几个小时现在正在寻找(和尝试)许多不同的方法,在获得无数"eacces permission denied"错误后,将一些文件写入我的4.4 Android KitKat的可移动SD卡.现在似乎Google对SD卡上的文件系统的访问权限有限,您只能写入应用程序拥有的目录(例如:/Android/data/com.mycompany.myapp/files/).
最后,我得到了一些工作,可以在可移动SD卡上创建一个可以写入的目录.但是我很好奇为什么为了获得对可移动SD卡上的这个拥有目录的访问,我首先必须使用外部目录的路径创建一个新的文件对象?
我的实施:
首先,我创建两个全局变量来容纳外部和可移动路径的字符串.
MainActivity
public class MainActivity extends ActionBarActivity {
String externalStorageDirectory;//path to owned external storage files
String secondaryStorageDirectory ;//path to owned removable storage files
Run Code Online (Sandbox Code Playgroud)
然后我询问系统调用制造商特定目录的内容,并开始连接externalStorage和removableStorage变量的绝对路径.我还创建了一个新的File对象,该对象使用外部应用程序拥有的目录的路径进行初始化.
onCreate()
externalStorageDirectory = this.getExternalFilesDir(null).toString();//build absolute path to the app owned external directory
File folder = new File(externalStorageDirectory ); //THIS LINE IS CRUCIAL!!
Log.d("DEBUG", " - External Path" + externalStorageDirectory );// "/storage/emulated/0/Android/data/com.mycompany.myapp/files"
String ownedDirectory = "/Android/data/" + this.getPackageName() + "/files/";
secondaryStorageDirectory = System.getenv("SECONDARY_STORAGE").toString() + ownedDirectory;//build absolute path to the app …Run Code Online (Sandbox Code Playgroud) 我最近购买了HTC Vive VR HMD,想知道它是否可用于可视化Python生成的数据?
在使用HMD可视化简单顶点/矢量时,是否有任何好的方法可以在HMD中可视化它们(并可能考虑了房间缩放功能)?
我对使用OpenGL的PyQtGraph有点熟悉,我真的在想/希望是否有可能进入该库并实现查看HMD中PyQtGraph数据的能力,并可能使用房间规模在它周围走动?
非常感谢您的投入!!
我有一个来自相机(灰度图像)的输入数组,如下所示:
[
[0.5, 0.75, 0.1, 0.6],
[0.3, 0.75, 1.0, 0.9]
]
Run Code Online (Sandbox Code Playgroud)
实际尺寸 = 434x512
我需要一个输出,它是一个 XYZ 坐标列表:
即 [[x,y,z],[x,y,z],...]
[[0,0,0.5],[1,0,0.75],[2,0,0.1],[3,0,0.6],[0,1,0.3],[1,1,0.75],[2,1,1.0],[3,1,0.9]]
Run Code Online (Sandbox Code Playgroud)
有没有什么有效的方法可以使用 Numpy 做到这一点?
我在保持 gridLayout 中所有元素的大小时遇到了一些麻烦。
有时,在我更新绘图数据(宽度和高度)后,内部小部件会完全改变大小,尤其是在最大化/最小化或更改窗口大小之后:
我希望实现的是无论窗口的尺寸如何,尺寸都保持均匀分布:
这是我为填充网格而编写的内容的摘要,以及我如何更新 CSS 以使边框更改颜色。我注意到,如果我不更改 CSS,那么这个问题就不明显了。
class ResultsViewer(QtGui.QWidget):
plots = {} #the currently displayed plot widgets
curves = {} #the currently displayed data that store the points
def __init__(self):
super(ResultsViewer, self).__init__()
self.win = QtGui.QMainWindow()
self.win.setCentralWidget(self)
self.win.resize(800, 250)
self.win.setWindowTitle("Cavity Results Viewer")
self.grid = QtGui.QGridLayout(self)
self.win.setWindowFlags(self.win.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)
def reset_indicators(self):
for plot in self.plots.keys():
self.plots[plot].setStyleSheet("""
border-top: 5px solid rgba(0,0,0,0);
border-radius: 12px;
""")
def set_indicator_border_color(self, cavnum, result):
color = "lime" if result['decision'] else "red"
self.plots[cavnum].setStyleSheet(""" …Run Code Online (Sandbox Code Playgroud) 我有一个字符串名称的 Python 列表,我想从所有名称中删除一个公共子字符串。
在阅读了这个类似的答案后,我几乎可以使用SequenceMatcher.
但只有当所有项目都有一个共同的子字符串时:
From List:
string 1 = myKey_apples
string 2 = myKey_appleses
string 3 = myKey_oranges
common substring = "myKey_"
To List:
string 1 = apples
string 2 = appleses
string 3 = oranges
Run Code Online (Sandbox Code Playgroud)
但是,我有一个稍微嘈杂的列表,其中包含一些不符合相同命名约定的分散项目。
我想从大多数中删除“最常见”的子字符串:
From List:
string 1 = myKey_apples
string 2 = myKey_appleses
string 3 = myKey_oranges
string 4 = foo
string 5 = myKey_Banannas
common substring = ""
To List:
string 1 = apples
string …Run Code Online (Sandbox Code Playgroud)