1

I'm wondering if there is a way to analyse each frame of my webcam video per second as an array of pixels. For example:

So if my resolution of my webcam was 3 x 3 (it's not) the I would get a constantly refreshing list of this form(or close).

pixel_list = [[(R, G, B), (R, G, B)], [(R, G, B), (R, G, B)], [(R, G, B), (R, G, B)]}

Thanks!

A lot of my googling has pushed me in the direction of opencv, but i'm not sure 'how' exactly to get what i need done.

2 Answers 2

2

Here ya go!

import cv2
cap = cv2.VideoCapture(-1)
while True:
    print(cap.read())

The new OpenCV API (module cv2) uses NumPy arrays for images.

Sign up to request clarification or add additional context in comments.

Comments

1

I recommend you to use Video4Linux to open your webcam, and to retrieve frames. Once youget the frames, you have pixel data. Here is a link to the Python binding for v4l: https://pypi.python.org/pypi/v4l2

Depending on what you need to do on the frames (which processing ?), opencv may be a good choice but for basic or even more advanced video data analysis, scipy is very good. There are also other image processing toolkits for Python.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.