opencv starts capture with a big zoom - python-2.7

I am building a stereo vision system, but when I start my videoCapture with opencv, the frame is zoomed. Instead of showing the whole face with background for example, it only shows a big zoom to the chin.
It is USB camera bought on Amazon, just a PCB with lens and USB cable. I can only set the focus with a screw on the lens.
Any ideas how I can solve this?

Related

Camera Calibration in Video Frames (mp4) without Chessboard or any marker

I am new in the field of computer vision and try to get the extrinsic camera parameters from video frames.
I have the intrinsic paremeters of my camera (focal length etc.). However, to analyse my video stream I would like to get the exttrinsic camera paremeters.
Is this possible via e.g SURF/ORB? anyone has experience with it? and can recommend some tutorials, preferably in Pyhton.

Feed GStreamer sink into OpenPose

I have a custom USB camera with a custom driver on a custom board Nvidia Jetson TX2 that is not detected through openpose examples. I access the data using GStreamer custom source. I currently pull frames into a CV mat, color convert them and feed into OpenPose on a per picture basis, it works fine but 30 - 40% slower than a comparable video stream from a plug and play camera. I would like to explore things like tracking that is available for streams since Im trying to maximize the fps. I believe the stream feed is superior due to better (continuous) use of the GPU.
In particular the speedup would come at confidence expense and would be addressed later. 1 frame goes through pose estimation and 3 - 4 subsequent frames are just tracking the object with decreasing confidence levels. I tried that on a plug and play camera and openpose example and the results were somewhat satisfactory.
The point where I stumbled is that I can put the video stream into CV VideoCapture but I do not know, however, how to provide the CV video capture to OpenPose for processing.
If there is a better way to do it, I am happy to try different things but the bottom line is that the custom camera stays (I know ;/). Solutions to the issue described or different ideas are welcome.
Things I already tried:
Lower resolution of the camera (the camera crops below certain res instead of binning so cant really go below 1920x1080, its a 40+ MegaPixel video camera by the way)
use CUDA to shrink the image before feeding it to OpenPose (the shrink + pose estimation time was virtually equivalent to the pose estimation on the original image)
since the camera view is static, check for changes between frames, crop the image down to the area that changed and run pose estimation on that section (10% speedup, high risk of missing something)

Videos captured from an iPhone camera appear to be rotated by 90 degrees by OpenCV? How do I get around this?

I shoot video from iPhone and convert each frame from colour to gray scale, however, the videos appear to be rotated by 90 degrees in OpenCV (4.1, C++)
the same issue doesnt show up on MATLAB or on VLC player (when I check)
Sample code
// frame
Mat current_frame;
VideoCapture capture("file_name.mov");
// Check - video file does not open for reading
if (!capture.isOpened())
throw "Error when reading steam_avi";
capture >> current_frame;
Rachit,
Phone cameras can record videos in four possible orientations:
landscape - camera to the left
landscape - camera to the right
portrait - camera at the top
portrait - camera at the bottom.
In each of these cases, a rotation flag is encoded into the video and it is upto the decoder to honour the flag and perform the suitable rotation when reading. I believe this is done for faster encoding performance.
MATLAB definitely honours this on Windows 10.
Windows 7 on the other hand does not honour this flag and you will see rotated videos. As MATLAB appears to use the Windows frameworks for reading, it will be rotated in MATLAB too.
Hope this helps.
Dinesh

Night Vision Video: Occupancy Detection using OpenCV C++

Using Raspberry Pi NoIR camera, I am trying to do occupancy detection using OpenCV for shared office space.
In order to identify vacant spots, I am using image of empty office space as a background model. Once we have the background model, I subtract the live video frame from the background image model(using cvAbsDiff) and identify the changes.
I am getting the images using a webcam mounted on the roof. The problem is to identify a person from this angle. When I work with live video, there are subtle variations (changes in chair position, physical objects or variations of camera) which act as noise. I tried using BackgroundSubtractorMOG, MOG2 but MOG and MOG2 can only do differences from a video stream but not using an image reference model.
Any inputs on possible directions will be greatly appreciated. I will be happy to share the technique with you guys that works once I have a working solution. Thanks!

Why does a full screen window resolution in OpenCV (# Banana Pi, Raspbian) slow down the camera footage and let it lag?

Currently I’m working on a project to mirror a camera for a blind spot.
The camera got 640 x 480 NTSC signal.
The output screen is 854 x 480 NTSC.
I grab the camera with an EasyCAP video grabber.
On the Banana Pi I installed open cv 2.4.9.
The critical point of this project is that the video on the display needs to be real time.
Whenever I comment the line that puts the window into fullscreen, there pop ups a small window and the footage runs without delay and lagg.
But when I set the video to full screen, the footage becomes slow, and lags.
Part of the code:
namedWindow("window",0);
setWindowProperty("window",CV_WND_PROP_FULLSCREEN,CV_WINDOW_FULLSCREEN);
while(1){
cap>>image;
flip(image, destination,1);
imshow("window",destination);
waitKey(33); //delay 33 ms
}
How can I fill the screen with the camera footage without losing speed and frames?
Is it possible to output the footage directly to the composite output?
The problem is that upscaling and drawing is done in software here. The Banana Pi processor is not powerful enough to process the needed throughput with 30 frames per second.
This is an educated guess on my side, as even desktop systems can run into lag problems when processing and simultaneously displaying video.
A common solution in the computer vision community for this problem is to use OpenGL for display. Here, the upscaling and display is offloaded to the graphics processor. You can do the same thing on a Banana Pi.
If you compiled OpenCV with OpenGL support, you can try it like this:
namedWindow("window", WINDOW_OPENGL);
imshow("window", destination);
Note that if you use OpenGL, you can also save on the flip operation by using an approprate modelview matrix. For this however you probably need to dive into GL code yourself instead of using imshow.
I fixed the whole problem by using:
namedWindow("window",1);
With FLAG 1 stands for WINDOW_AUTOSIZE.
The footage is more real-time now.
I’m using a small monitor, so the window size is nearly the same as the monitor.