现在,我有一个python代码,它使用pyrealsense2
、cv2
、tensorflow
来读取tensorflow模型。我已经用cythonized它而没有将.py
更改为.pyx
即我没有用cdef
更改任何变量,因为大多数变量都依赖于指定的库。你知道吗
我有一项关于如何使用上的cdef
部分的研究,例如从到pyrealsense2
,但是这些来源让我一无所获。我只能找到一些cv2
包装,但对我来说还不够。此外,我是cython
的新人。所以,我也很难把它转换成cython
。你知道吗
是否真的有可能优化和加速具有tensorflow + pyrealsense2 + cv2
的代码?我确信我可以为cv2
部分做些什么,但最重要的是尽可能减少模型的推理时间。你知道吗
我的目标是转化例如:
pipeline = rs.pipeline()
config_rs = rs.config()
config_rs.enable_stream(rs.stream.depth, 848, 480, rs.format.z16, FRAME_RATE)
config_rs.enable_stream(rs.stream.color, 848, 480, rs.format.bgr8, FRAME_RATE)
frames = pipeline.wait_for_frames()
try:
while True:
depth_frame = frames.get_depth_frame()
color_frame = frames.get_color_frame()
if not depth_frame or not color_frame:
continue
depth_image = np.asanyarray(depth_frame.get_data())
color_image = np.asanyarray(color_frame.get_data())
x, y = sess.run([x_, y_], feed_dict={input_img: [depth_img]})
变成这样:
cdef "type of this" pipeline = rs.pipeline()
cdef "type of this" config_rs = rs.config()
config_rs.enable_stream(rs.stream.depth, 848, 480, rs.format.z16, FRAME_RATE)
config_rs.enable_stream(rs.stream.color, 848, 480, rs.format.bgr8, FRAME_RATE)
cdef "type of this" frames = pipeline.wait_for_frames()
try:
while True:
cdef "type of this" depth_frame = frames.get_depth_frame()
cdef "type of this" color_frame = frames.get_color_frame()
if not depth_frame or not color_frame:
continue
cdef "type of this" depth_image = np.asanyarray(depth_frame.get_data())
cdef "type of this" color_image = np.asanyarray(color_frame.get_data())
cdef "type of them" x, y = sess.run([x_, y_], feed_dict={input_img: [depth_img]})
首先,感谢您的帮助,我倾向于优化tensorflow + pyrealsense2
部分,但我想听听其他类型优化的建议(可能我还没有读到它们)。你知道吗
注意:有些人可能会建议我使用TensorRT,但遗憾的是我使用的是Windows机器。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐