reference resources: http://stackoverflow.com/questions/13572448/change-values-in-a-numpy-array
###################################################################3
Get the video stream from the raspberry pie camera and convert it to opencv format:
http://blog.csdn.net/u012005313/article/details/51482994
At the same time, you want to operate on each frame, but there is an error:
ValueError:assignment destination is read-only
Images cannot be manipulated because they are read-only.
Find a way on stackhover: because in Python, the opencv image format is Numpy.ndarray You can modify the properties of ndarray by:
img.flags.writeable = True
####################################################################
Numpy.ndarray It has the following attributes:
C_ CONTIGUOUS(c_ contiguous)
F_ CONTIGUOUS(f_ contiguous)
OWNDATA(owndata)
WRITEABLE(writeable)
ALIGNED(aligned)
UPDATEIFCOPY(updateifcopy)
import numpy as np
help(np.ndarray.flags)
The flags property is information about the array memory layout
Among them, the flags attribute can be modified in the form of a dictionary, for example:
a.flags['WRITEABLE'] = True
You can also use lowercase attribute names:
a.flags.writeable = True
Abbreviations (‘c ‘/’f’, etc.) are only used in dictionary form
Only the attributes updateifcopy, writeable and aligned can be modified by users in three ways
1. Direct assignment:
a.flags.writeable = True
2. Dictionary input:
a.flags['WRITEABLE'] = True
3. Use function ndarray.setflags :
help(np.ndarray.setflags)