接收到numpy阵列中

2024-04-18 21:37:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我用运行wince的摄像头通过插座传输图像:( 相机中的图像只是使用realloc为给定的x*y大小创建的浮动数组

另一方面,我用python接收这些图像。 我有代码在工作

img_dtype = np.float32
img_rcv = np.empty((img_y, img_x), 
                   dtype = img_dtype)

p = sck.recv_into(img_rcv, 
                  int(size_bytes), 
                  socket.MSG_WAITALL)

if size_bytes != p:
    print "Mismatch between expected and received data amount"


 return img_rcv

我对numpy创建数组的方式有点困惑,我想知道这个img峎u rcv是否与recv_into的工作方式兼容。在

我的问题是:

  • 这有多安全?在
  • numpy数组的内存分配是否为recv\u into所知?在
  • numpy数组创建例程是否等同于malloc?在
  • 只是因为我运气好才有用?在

Tags: 图像numpyimgsizebytesnp方式数组