Ask Your Question

Jaman42's profile - activity

2019-11-11 18:19:12 -0500 received badge  Popular Question (source)
2019-07-21 01:54:31 -0500 received badge  Popular Question (source)
2015-01-19 04:04:47 -0500 asked a question VideoCapture read non blocking?

I am programming in Python, Pygame from what I understand uses opencv for its webcam functions. There is a query_image() available that polls the camera so you can start fetching a frame only when there is a frame to fetch, for example:

pygame.init()
pygame.camera.init()
webcam = pygame.camera.Camera("/dev/video0",(320,240))
webcam.start()
if(webcam.query_image()):
    image = webcam.get_image()

When I use the following code with opencv:

cap = cv2.VideoCapture(0)
rval, frame = cap.read()

It waits until the frame is fetched which is for me undesirable, is there a way to poll the camera before trying to fetch to see if there is a frame available?

2015-01-12 04:18:27 -0500 commented question What is limiting my FPS?

I got the new webcamera and did get 30fps using the same code, my camera didn't handle low lighting very well but with the help of a flashlight I got there :)

2015-01-12 04:18:27 -0500 received badge  Enthusiast
2015-01-09 12:11:57 -0500 commented question What is limiting my FPS?

I think I misunderstood you, I am using a release build of Opencv. I thought interpreted languages like Python was slower then compiled like C, it isn't? Or just to little to notice doing something like this?

2015-01-08 11:46:29 -0500 commented question What is limiting my FPS?

Hi thank you for your answer, the code I posted is what I tried. Just as a test to see what FPS I could achieve. I tried it on my main PC to see if it was any different and it wasn't. That should mean that the webcam is the issue assuming I can get much better result with the code above. I ordered a new webcam that can deliver 30 fps to test with. Is it much quicker to do it in c or should I be able to get good results with Python as well?

2015-01-05 13:39:59 -0500 asked a question What is limiting my FPS?

Hi, I plan on building a ROV and I am working on my video feed atm. I will be using fiber optics for all communications and I am tinkering with opencv to stream a webcam feed with python. I might choose to use IP cameras but I wanted to learn more about how to capture frames from a webcam in python first. Since I didn't know what I was going to use in the end I bought a cheap-as-they-get noname USB webcam just to try and get everything working. This camera feed is going to be used for navigation, a seperate video recorder will probably be used for recording video.

Enough about that, now to my issue. I am getting only 8 FPS when I am capturing the frames but I suspect that is due to the cheap webcam. The webcam is connected to a pcduino 3 nano which is connected to a arduino for controlling thrusters and reading sensors. I never thought of how to utilize hardware in encoding and decoding images, I don't know enough about that part yet to tell if I can utilize any of the hardware.

Do you guys believe it's my web cam that is the bottleneck? Is it a better idea to use a IP camera or should I be able to get a decent FPS using a webcam connected to a pcduino 3 nano capturing frames with opencv?

Im programming in Python, this is the test I made:

import cv2, time
FPS = 0
cap = cv2.VideoCapture(0)

last = time.time()

for i in range(0,100):
    before = time.time()
    rval, frame = cap.read()
    now = time.time()
    print("cap.read() took: " + str(now - before))
    if(now - last >= 1):
        print(FPS)
        last = now
        FPS = 0
    else:
        FPS += 1
cap.release()

And the result is in the line of:

cap.read() took: 0.118262052536
cap.read() took: 0.118585824966
cap.read() took: 0.121902942657
cap.read() took: 0.116680860519
cap.read() took: 0.119271993637
cap.read() took: 0.117949008942
cap.read() took: 0.119143009186
cap.read() took: 0.122378110886
cap.read() took: 0.116139888763