有没有办法访问用opencv拍摄的帧进行加密?
It s there any way to acces the frames taken with opencv for encription?
我尝试进行一个加密的视频会议,所以数据将以 UDP 模式发送,我在 python 中使用 openCV 访问了网络摄像头,是否有任何方法可以从网络摄像头访问数据作为位所以我可以 encript-transfer-decript 并在所需的电台上显示图像吗?或者还有什么其他库 (python/java/c/c++) 可以帮助我从网络摄像头获取数据?
我在 Ubuntu 16.04 上为 Python(3.5) 使用 OpenCV 3.3。
对于你的问题,要加密从视频中提取的帧并通过 TCP/UDP 进行转换:
On Side A:
(1) use `cap.read` to take frame form `videoCapture` as `np.array`
(2) use `np.tobytes` to convert from `np.array` to `bytes`
(3) do encryption on bytes(can be switched with step 2).
(4) transfer `bytes` using TCP/UDP
On Side B:
(1) receive from A
(2) do decryption on the received bytes
(3) use `np.frombuffer` to convert from `bytes` to `np.array`, then `reshape`. you get the data.
示例代码片段:
- On Side A
cap = cv2.VideoCapture(0)
assert cap.isOpened()
## (1) read
ret, frame = cap.read()
sz = frame.shape
## (2) numpy to bytes
frame_bytes = frame.tobytes()
print(type(frame_bytes))
# <class 'bytes'>
## (3) encode
# ...
## (4) transfer
# ...
cap.release()
- On Side B
## (1) receive
## (2) decode
## (3) frombuffer and reshape to the same size on Side A
frame_frombytes = np.frombuffer(frame_bytes, dtype=np.uint8).reshape(sz)
print(type(frame_frombytes))
## <class 'numpy.ndarray'>
相关回答:
(1)
(2) Can't write video by opencv in Python
(3)
我尝试进行一个加密的视频会议,所以数据将以 UDP 模式发送,我在 python 中使用 openCV 访问了网络摄像头,是否有任何方法可以从网络摄像头访问数据作为位所以我可以 encript-transfer-decript 并在所需的电台上显示图像吗?或者还有什么其他库 (python/java/c/c++) 可以帮助我从网络摄像头获取数据?
我在 Ubuntu 16.04 上为 Python(3.5) 使用 OpenCV 3.3。
对于你的问题,要加密从视频中提取的帧并通过 TCP/UDP 进行转换:
On Side A:
(1) use `cap.read` to take frame form `videoCapture` as `np.array`
(2) use `np.tobytes` to convert from `np.array` to `bytes`
(3) do encryption on bytes(can be switched with step 2).
(4) transfer `bytes` using TCP/UDP
On Side B:
(1) receive from A
(2) do decryption on the received bytes
(3) use `np.frombuffer` to convert from `bytes` to `np.array`, then `reshape`. you get the data.
示例代码片段:
- On Side A
cap = cv2.VideoCapture(0)
assert cap.isOpened()
## (1) read
ret, frame = cap.read()
sz = frame.shape
## (2) numpy to bytes
frame_bytes = frame.tobytes()
print(type(frame_bytes))
# <class 'bytes'>
## (3) encode
# ...
## (4) transfer
# ...
cap.release()
- On Side B
## (1) receive
## (2) decode
## (3) frombuffer and reshape to the same size on Side A
frame_frombytes = np.frombuffer(frame_bytes, dtype=np.uint8).reshape(sz)
print(type(frame_frombytes))
## <class 'numpy.ndarray'>
相关回答:
(1)
(2) Can't write video by opencv in Python
(3)