一、总结

一句话总结:

List转numpy.array:temp = np.array(list)
numpy.array转List:arr = temp.tolist()

 

 

二、list和numpy互相转换

转自或参考:python中List类型与numpy.array类型的互相转换
https://blog.csdn.net/Liuseii/article/details/80023733

当然要先引入numpy包

import numpy as np

List转numpy.array:

temp = np.array(list) 

numpy.array转List:

arr = temp.tolist() 

原来是打算使用这种转换直接编辑OpenCV中的Mat类,后来发现不用转换,可以直接将一个Mat类当做三维数组来提到其中的每一个像素。同时按照这种方式转换的类型,opencv输出会是一张黑图,所以放弃。

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-01
  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2022-02-10
  • 2021-07-20
相关资源
相似解决方案