emgucv

Fastest way to get number of white pixels in a binary image using OpenCV

给你一囗甜甜゛ 提交于 2019-11-30 20:41:10
What is the fastest way to get number of white pixels in a binary picture using OpenCV? Is there something faster than using two for loops and accessing the image pixel by pixel? The most succinct way to accomplish this is: cv::Mat image, mask; //image is CV_8UC1 cv::inRange(image, 255, 255, mask); int count = cv::countNonZero(mask); If you are operating on a binary image, then the call to cv::inRange() is unnecessary, and simply cv::countNonZero() will suffice. Although any method must iterate through all the pixels, this may be able to harness OpenCV's built-in parallel_for_() , which allows

Controlling mouse pointer through camshift algorithm of OpenCV (or how mouse basically functions)

冷暖自知 提交于 2019-11-30 20:21:24
问题 I have written a program in C# using EmguCV (wrapper of openCV). The program tracks an object using camshift algorithm. A rectangle is drawn around the object. The cursor is moved by center of the rectangle. Input is taken from a webcam. Initially the problem was that the cursor couldn't cover the entire screen. Its movement was limited to frame size. And so i applied a multiplication factor: screenwidth/framewidth for movement in X direction. screenheight/frameheight for movement in Y

emguCV 3.1 - face detection

为君一笑 提交于 2019-11-30 19:31:37
问题 I'm new to OpenCV/EmguCV in C#. I tried a tutorial (http://fewtutorials.bravesites.com/entries/emgu-cv-c/level-3---live-face-detection) and the video captureing with the webcam was easy. Now my problem: The tutorial was written for EmguCV 2.x. I'm using EmguCV 3.1 (I like to use the newest). Therefor I used the class Mat instead of the class Image<> . The class Image<> hasn't worked with capture.QueryFrame(); But when I come to face detection, the tutorial says I should use the classes

Trouble with locking an image between threads

家住魔仙堡 提交于 2019-11-30 16:18:17
问题 I need to obtain a lock in two different threads in order to access a Bitmap (which is populated from a webcam) in EmguCv. I have a "GetFrame" functions that queries the camera and places what it returns into a .NET Bitmap. I have two threads which need to access this Bitmap, one needs to write to the Bitmap and assign the Bitmap to a picture box, and the other needs to read the Bitmap, convert it to an Image object and assign that to an EMGU ImageBox. I first lock on an arbitrary Object,

Conversion to grayscale using emguCV in C#

我的未来我决定 提交于 2019-11-30 14:57:00
问题 I am new to EmguCV. I want to convert an rgb image into gray scale. For the conversion I have used the code Image<Gray,byte> grayImage = ColordImage.Convert<Gray, byte>(); Now when i compile this code in C# it gives no error,but when i run it then after a few seconds it gives me the exception at this line of code that this type of conversion is not supported by OpenCV. Now can any one help me solve this problem. Regards Amal 回答1: It may depend on the type of colour that ColordImage is. For

Convert from yuv 420 to image<Bgr,byte>

两盒软妹~` 提交于 2019-11-30 14:53:13
I have byte array with yuv420 data. byte[] yuv420;//yuv data How can I convert this to an Image<Bgr, byte> ? I found a math formula to convert to RGB and then to Image<Bgr, byte> but it is very slow. Is there a way to convert it faster? There is a class in Emgu for converting COLOR_CONVERSION(enum CV_YUV2RGB Convert YUV color to RGB) but I can not understand how use this class. Can anyone help? static Bitmap ConvertYUV2RGB(byte[] yuvFrame, byte[] rgbFrame, int width, int height) { int uIndex = width * height; int vIndex = uIndex + ((width * height) >> 2); int gIndex = width * height; int

How to find a black square with any angle of rotation in the image using emgu cv

跟風遠走 提交于 2019-11-30 14:25:20
问题 I need to find the coordinates of three black squares in the test form. I took the example code from the site emgu.com and slightly changed it, but he does not find what I need. The size of image is A4, and the size of the test form is A5. I am hope for your help :) I nearly forgot, the size of squares 30 pixels. private void DetectRectangles(Image<Gray, byte> img) { var size = new Size(3, 3); CvInvoke.GaussianBlur(img, img, size, 0); CvInvoke.AdaptiveThreshold(img, img, 255,

How to find a black square with any angle of rotation in the image using emgu cv

房东的猫 提交于 2019-11-30 10:34:01
I need to find the coordinates of three black squares in the test form. I took the example code from the site emgu.com and slightly changed it, but he does not find what I need. The size of image is A4, and the size of the test form is A5. I am hope for your help :) I nearly forgot, the size of squares 30 pixels. private void DetectRectangles(Image<Gray, byte> img) { var size = new Size(3, 3); CvInvoke.GaussianBlur(img, img, size, 0); CvInvoke.AdaptiveThreshold(img, img, 255, AdaptiveThresholdType.MeanC, ThresholdType.Binary, 75, 100); UMat cannyEdges = new UMat(); CvInvoke.Canny(img,

OpenCV (Emgu.CV) — compositing images with alpha

孤街醉人 提交于 2019-11-30 09:26:53
I'm using Emgu.CV to perform some basic image manipulation and composition. My images are loaded as Image<Bgra,Byte> . Question #1: When I use the Image<,>.Add() method, the images are always blended together, regardless of the alpha value. Instead I'd like them to be composited one atop the other, and use the included alpha channel to determine how the images should be blended. So if I call image1.Add(image2) any fully opaque pixels in image2 would completely cover the pixels from image1, while semi-transparent pixels would be blended based on the alpha value. Here's what I'm trying to do in

How to calculate Rotation and Translation matrices from homography?

一世执手 提交于 2019-11-30 07:42:06
I have already done the comparison of 2 images of same scene which are taken by one camera with different view angles(say left and right) using SURF in emgucv (C#). And it gave me a 3x3 homography matrix for 2D transformation. But now I want to make those 2 images in 3D environment (using DirectX). To do that I need to calculate relative location and orientation of 2nd image(right) to the 1st image(left) in 3D form. How can I calculate Rotation and Translate matrices for 2nd image? I need also z value for 2nd image. I read something called 'Homograhy decomposition'. Is it the way? Is there