OpenCV in Android Studio

The below steps for using Android OpenCV sdk in Android Studio. This is a simplified version of this(1) SO answer. Download latest OpenCV sdk for Android from OpenCV.org and decompress the zip file. Import OpenCV to Android Studio, From File -> New -> Import Module, choose sdk/java folder in the unzipped opencv archive. Update build.gradle … Read more

OpenCV C++/Obj-C: Detecting a sheet of paper / Square Detection

This is a recurring subject in Stackoverflow and since I was unable to find a relevant implementation I decided to accept the challenge. I made some modifications to the squares demo present in OpenCV and the resulting C++ code below is able to detect a sheet of paper in the image: void find_squares(Mat& image, vector<vector<Point> … Read more

Video Streaming from IP Camera in Python Using OpenCV cv2.VideoCapture

You’re most likely getting that error due to an invalid stream link. Insert your stream link into VLC player to confirm it is working. Here’s a IP camera video streaming widget using OpenCV and cv2.VideoCapture.read(). This implementation uses threading for obtaining frames in a different thread since read() is a blocking operation. By putting this … Read more

Python OpenCV streaming from camera – multithreading, timestamps

Using threading to handle I/O heavy operations (such as reading frames from a webcam) is a classic programming model. Since accessing the webcam/camera using cv2.VideoCapture().read() is a blocking operation, our main program is stalled until the frame is read from the camera device and returned to our script. Essentially the idea is to spawn another … Read more

Java code to draw ellipse around face

x and y correspond to the top-left vertex of the rectangle. Given that the function you’ve specified takes only 4 parameters, I’m guessing it is an upright ellipse that you’re drawing. If you’ve found the code to draw rectangles around faces, then you should be able to extract (x,y) from there itself

How to read video stream as input in OpenCV python?

I agree with the comments above, more details are needed to know exactly how you are planning connect your camera. Here’s a working example for a webcam, notice that you should replace the input_id with your camera’s. You would work on frame for further processing. import cv2 def get_video(input_id): camera = cv2.VideoCapture(input_id) while True: okay, … Read more