Python3 & OpenCV3 [ Part 3 : Function Video] 😝

Nonpavit Detbun 🔋🍺
2 min readSep 9, 2018

--

เรียนรู้พื้นฐานคำสั่ง OpenCV : Video

จากบทความที่แล้ว เราได้สอนการจัดการกับ Image กันไปบ้างแล้ว
ครั้งนี้เราจะมาดูคำสั่งพื้นฐานในการจัดการ Videoกัน 💻

open terminal in VS Code (Ctrl + `)

workon opencv

Basic Function Video OpenCV

cv2.cvtColor(var_image/var_video, type_change_color)

  • cv2.cvtColor() : เป็นคำสั่งสำหรับเปลี่ยนสีของรูปภาพและวิดีโอ
  • จาก BGR → Gray ใช้ cv2.COLOR_BGR2GRAY
  • จาก BGR → HSV ใช้ cv2.COLOR_BGR2HSV
  • ไม่เปลี่ยนสี ใช้ 0

cv2.VideoCapture(select_camera/file_video)

  • cv2.VideoCapture() : เลือกกล้องที่เชื่อมต่อกับอุปกรณ์ ถ้าเลือกกล้องภายในใช้คำสั่ง cv2.VideoCapture(0) → โดยระบบจะเริ่มนับตั้งแต่กล้องที่ 0 (ภายใน)

Ex. cv2.cvtColor() & cv2.VideoCapture() → Live Stream

cv2.VideoWriter(file_video,fourcc, frame_per_second, (x_axis,y_axis))

  • cv2.VideoWriter() : อัดวิดีโอลงไฟล์

cv2.VideoWriter_fourcc(FourCC code)

  • cv2.VideoWriter_fourcc() : video codec
  • Fedora: DIVX, XVID, MJPG, X264, WMV1, WMV2
  • Windows: DIVX, XVID

Ex. cv2.VideoWriter() & cv2.VideoWriter_fourcc()→ Writer Video

Ex. → Play Video

……………………………………………………………………………………….

Source Code :

แล้วพบกันใหม่ Part 4เราจะมารู้จักกับ Tricks ต่างๆกัน 😵

……………………………………………………………………………………….

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Nonpavit Detbun 🔋🍺
Nonpavit Detbun 🔋🍺

Written by Nonpavit Detbun 🔋🍺

I’m Electrical Engineering. 📟 I have an interest in Web App, Mobile App, IoT and Microcontroller 🧐

No responses yet

Write a response