PythonOpenCvを使用してリバースモードでビデオを再生する
OpenCvの完全な形式はオープンソースのコンピュータービジョンであり、このライブラリを使用して、画像やビデオに対してさまざまな操作を実行できます。
OpenCVのアプリケーション領域
- 顔認識システム
- モーショントラッキング
- 人工ニューラルネットワーク
- ディープニューラルネットワーク
- ビデオストリーミングなど
Windowsにインストールする場合は、このコマンドラインを使用できます
pip install opencv-python
Linuxの場合-
sudo apt-get install python-opencv
タスクを完了するには、いくつかの手順に従う必要があります-
Step 1: We import OpenCv library named cv2. Step 2: Take a video as input data. Step 3: First we break the video into a number of frames and store all these frames in a list. Step 4: When we are getting all the frames then we shall apply iteration method. Step 5: Here we apply iteration for reversing the list. Step 6: Use the reverse() method for reversing the order of the frames in the list.
サンプルコード
import cv2
# Grab the current frame.
my_check , vid = cap.read()
# use counter variable for
# Counting frames
counter = 0
check = True
frame_list = []
while(check == True):
cv2.imwrite("frame%d.jpg" %counter , vid)
check , vid = cap.read()
frame_list.append(vid)
# increment the counter by 1
counter += 1
frame_list.pop()
# looping in the List of frames.
for frame in frame_list:
# show the frame.
cv2.imshow("Frame" , frame)
if cv2.waitKey(25) and 0xFF == ord("q"):
break
cap.release()
# close any open windows
cv2.destroyAllWindows()
frame_list.reverse()
for frame in frame_list:
cv2.imshow("Frame" , frame)
if cv2.waitKey(25) and 0xFF == ord("q"):
break
cap.release()
cv2.destroyAllWindows() 出力
-
PythonOpenCvモジュールを使用したヒストグラムの等化
これは、画像のヒストグラムを使用してコントラスト調整を行う画像処理の方法です。 実際、この方法は通常、多くの画像のグローバルコントラストを増加させます。特に、画像の使用可能なデータが近いコントラスト値で表される場合、この調整により、強度をヒストグラム上でより適切に分散でき、ローカルコントラストの低い領域が可能になります。より高いコントラストを得る。 OpenCVにはこれを行う関数cv2.equalizeHist()があり、その入力は単なるグレースケール画像であり、出力はヒストグラム均等化された画像です。 この手法は、画像のヒストグラムが特定の領域に限定されている場合に適しています。強度の
-
PythonOpenCvモジュールを使用して画像に幾何学的形状を描画します
OpenCVの基本的な操作は、画像を描画することです。線、円、長方形などのさまざまな幾何学的形状を追加する機能。 多くの場合、画像分析を使用して、画像の一部を強調表示する必要があります。たとえば、その部分を定義する長方形を追加します。また、例として、何かを示す矢印。 cv2.line()-この関数は、画像に線を引くために使用されます。 cv2.rectangle()-この関数は、画像に長方形を描画するために使用されます。 cv2.circle()-この関数は、画像に円を描くために使用されます。 cv2.putText()-この関数は、画像にテキストを書き込むために使用されます。 c