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)
Read More:
- Dataframe to numpy.ndarray Related issues of
- AttributeError: ‘numpy.ndarray‘ object has no attribute ‘softmax‘
- Python read / write file error valueerror: I/O operation on closed file
- Pandas read_ Error in json() valueerror: training data
- Tensorflow ValueError: Failed to convert a NumPy array to a Tensor
- Python ValueError: only 2 non-keyword arguments accepted
- C + + programming fault handling — error: assignment of read only data member ‘STD:: pair
- Python error: local variable ‘XXXX’ referenced before assignment
- Python UnboundLocalError: local variable ‘num’ referenced before assignment
- Solving Python error: local variable ‘a’ referenced before assignment
- Memory error in Python numpy matrix
- No module named numpy error in Python code
- Python_ Part 2 programming problems (3)_ solve numpy.core.multiarray Failed to import problem
- Differences between shell script variable assignment and C language variable assignment
- Warning when using numpy: runtimewarning: numpy.dtype size changed, may indicate binary incompatibility
- UserWarning: Failed to initialize NumPy: No module named ‘numpy.core._multiarray_umath‘
- Python error type error: ‘range’ object does not support item assignment, solution
- Unable to call numpy in pychar, module notfounderror: no module named ‘numpy’
- Assignment under multiple single edges is not supported for synthesis
- Python3-ValueError:not enough values to unpack (expected 2, got 0)