FAQ Database Discussion Community


How to read the data of a raw image in python - approach

python,opencv,image-processing,numpy
I am interested in reading the rgb data of a raw image using python. I would like to analyze the rgb of the RAW image with NO filtering and processing done by the DSLR. How would you recommend proceeding? What library etc.? Storing as a numpy array, if possible would...

MPI send struct with bytes array and integers

c++,opencv,struct,mpi,mat
I would like to send image data(array of unsigned char), width and height from rank 0 to rank 1. What is the best way to do this? I've read that to send complex data structure in MPI we can use packaging data or create own data type. What is better...

opencv convertTo not working

c++,opencv
I know this question has been asked and answered by others. But I still can't not solve my question. I read a frame from a video, which has format unsigned char (CV_8U). I hope to convert it to double precision(CV_64F). I do as following: VideoCapture capture(fileName); Mat image; capture >>...

Optimizing point - circle distance method

python,opencv,numpy,optimization,cython
I'm implementing a RANSAC algorithm for circle detection in images. I profiled the execution and I get: 13699392 function calls in 799.981 seconds Random listing order was used ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 0.000 0.000 {time.time} 579810 0.564 0.000 0.564 0.000 {getattr} 289905 2.343 0.000 8.661...

Creating and referencing a library for Android project (using command line and gradle)

java,android,linux,opencv,gradle
I need to create an Android app that uses the OpenCV library, and I would like to do this using the command line (linux) only. Before I start I wanted to get a feel for creating projects that use libraries, but I am having trouble referencing a sample library I...

Finding 3D coordinate of object

opencv,image-processing,3d,camera-calibration
I try to find 3D coordinate (in world )of abject that I know his coordinate in image .so after some research in internet I succed to find X and Y cordinate. but I can't find Z that is my program in openCV void drawAndCalcul3D(int x,int y,Mat& frame) { cv::Mat uvPoint...

UnsatisfiedLinkError while executing new Mat()

java,opencv,netbeans
i am currently trying to code a little program to take picture of newly students and save them by their names etc to ease the inscriptions things etc. So here is my problem, i found a great tutorial to help me using a webcam: http://www.codeproject.com/Tips/717283/How-to-use-OpenCV-with-Java-under-NetBeans-IDE I can run this project...

OpenCV - Detection of moving object C++

c++,opencv
I am working on Traffic Surveillance System an OpenCv project, I need to detect moving cars and people. I am using background subtraction method to detect moving objects and thus drawing counters. I have a problem : When two car are moving on road closely them my system detects it...

ImportError: No module named opencv after installing python-opencv in Ubuntu 14.04

python,opencv,ubuntu,install,ubuntu-14.04
I install opencv in python with running $ sudo apt-get install python-opencv and installed successfully. but when run this code import opencv import opencv.highgui import time import commands def get_image(): image = opencv.highgui.cvQueryFrame(camera) return opencv.adaptors.Ipl2PIL(image) camera = opencv.highgui.cvCreateCameraCapture(-1) while 1: image = get_image() image.thumbnail((32, 24, )) image = tuple(ord(i) for...

Rotate image without cropping OpenCV

python,opencv,image-processing
The question is how to rotate image using OpenCV and keep original dimensions. Currently using this function: def rotateImage(image, angle): (h, w) = image.shape[:2] center = (w / 2, h / 2) M = cv2.getRotationMatrix2D(center,angle,1.0) rotated_image = cv2.warpAffine(image, M, (w,h)) return rotated_image Additionally what kind of algorithm utilised in warpAffine...

How to generate an RGB Histogram by opencv

python,c++,opencv
I want to do a feature extraction from an image to a 3D histogram in the RGB colorspace. I have the following python code which I want to do it under c++: hist = cv2.calcHist([image], [0, 1, 2], None, self.bins, [0, 256, 0, 256, 0, 256]) hist = cv2.normalize(hist) return...

MPI - sending parts of image to different processes

c++,opencv,mpi
I'm writing a program in which process 0 sends parts of image to other processes which transform (long operation) this part and send back to the rank 0. I have a problem with one thing. To reproduce my issue I wrote a simple example. An image with size 512x512px is...

Extract from image an smaller image

c,image,opencv,captcha
I am starting learning an openCV and a have question about it. My target is to recognize captcha. First I must preprocess an image. There is an example of captcha here So problem is how to crop symbols from image and put it into 2D array(bitmap). ...

How to convert cv::Mat to MFC CBitmap

c++,opencv,mfc
how can I convert an OpenCV image to an Microsoft Foundation Classes (MFC) CBitmap object? I tried the following, which failed, cv::Mat tmp; (Load opencv image ...) cv::Size size = tmp.size(); CBitmap bitmap; // 3 colors (RGB), 24bits (8bits*3channels) if (!bitmap.CreateBitmap(128, 128, 1, 24, (void *)tmp.data)) { TRACE0("Failed to create...

Convert jpg image in ppm P3 ASCII format using Opencv

c++,opencv,jpeg,ppm
Using opencv imwrite function I managed to convert jpg image in ppm P6 format. Mat image = imread(picPath); vector<int> compression_params; compression_params.push_back(CV_IMWRITE_PXM_BINARY); compression_params.push_back(1); imwrite("bez.ppm", image, compression_params); Problem is that I actually have to convert jpg image in ppm P3 ASCII format. Does anyone know how to do it? Thanks! EDIT: In...

How to install shared library and include files manually in linux?

linux,opencv,cmake,raspberry-pi
I am trying to build and install TBB library from source so that it can be used for OpenCV to take advantages of multiple cores on my raspberry pi. I was able to build TBB from source without any problems using this steps. (Source : How do I build OpenCV...

What's the fastest way to compare point elements with each other´╝čI have used Nested for loop to do that, but it's very slow

c++,opencv,for-loop,dictionary,vector
I want to find the points which the distant between points less than 3.For example, some points as follow, (220,221)(220,119)(220,220)(20,90)(220,222). I use (220,221) to find points.Then i can get (220,221)(220,119)(220,220)(220,222) I use (220,119) to find points.Then i can get (220,221)(220,119)(220,220) I have used Nested for loop to do that, but...

numpy.where() on grayscale frame, wrong indices?

python,opencv,numpy,matplotlib,ransac
I'm trying to implement a basic RANSAC algorithm for the detection of a circle in a grayscale image. The problem is that, after I thresholded the image and I search for non-zero pixels I get the right shape, but the points are somehow delocalized from the original position: video =...

cv2.polylines gives wrong shape

python,opencv,numpy
I try to draw a reversed triangle with the code below,but it gives a normal triangle, even though the points I give are these of a reversed triangle! Could anybody tell me what I do wrong? import cv2 import numpy as np f=cv2.imread("C:\Desktop\image.jpg") pts = np.array([[195,327],[378,327],[286,144]]) pts = pts.reshape((-1,1,2)) cv2.polylines(f,np.int32([pts]),True,(0,0,255),3)...

imshow is not working

c++,opencv,image-processing
I used a for loop for reading 300 frames and for accumulating them.I gave an imshow command inside to print the frames continuously but they are not printed during the for loop is processing but it comes as a single image Here's my code: enter code here #include<iostream> #include "opencv2/highgui/highgui.hpp"...

Camera Calibration with OpenCV: Using the distortion and rotation-translation matrix

c++,opencv,computer-vision,robotics
I am reading the following documentation: http://docs.opencv.org/doc/tutorials/calib3d/camera_calibration/camera_calibration.html I have managed to successfully calibrate the camera obtaining the camera matrix and the distortion matrix. I had two sub-questions: 1) How do I use the distortion matrix as I don't know 'r'? 2) For all the views I have the rotation and...

c++ read in image set with different file names without hardcoding

c++,image,opencv,boost,image-loading
Is there any way of reading in a set of images from file that all have varying names to each other, i.e. no continuity at all? So if you had 4 images in the same folder with the file names of: head.jpg shoulders.png knees.tiff toes.bmp Without hard coding the file...

Access violation reading location when calling cudaMemcpy2DToArray

c++,arrays,opencv,cuda
I allocated a 2D array in device and want to copy a 2D float array to device. ImgSrc is a Mat type in openCV that I copied the elements of it into a 2D float array named ImgSrc_f.then by using cudaMemcpy2DToArray() I copied my host 2D array(ImgSrc_f) to device 2D...

adaptive thresholding ---ValueError: too many values to unpack

python,opencv,image-processing,adaptive-threshold
I'm pretty amateur at image processing. I could successfully do normal thresholding but however I'm facing an error in Adaptive Thresholding. Here is my code: import cv2 import numpy as np img = cv2.imread("vehicle004.jpg") img = cv2.medianBlur(img,5) gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) _,th2=cv2.adaptiveThreshold(gray,255,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY,11,2) cv2.imshow("window2",th2) cv2.waitKey(0) cv2.destroyAllWindows() Error Message: line 7, in <module>...

How to manipulate CameraPreview bytearray through the JNI? (OpenCV)

java,android,c++,opencv,jni
inside my "public void onPreviewFrame(byte[] data, Camera camera) { .... }" I want to take the bytearray "data" and pass it to the JNI and apply some OpenCV filters so that the preview changes, without returning it. What is the best way to do this? Currently I only pass the...

Opencv: EM algorithm training slowly

c++,algorithm,opencv
I am trying to use opencv EM algorithm library. I tried some example about EM algorithm such like this and this first, but I got the same problem in these code. It take me lots of time in EM training step. This is my testing code for image segmentation from...

Trying to write a UDP streaming webcam service on C

c,opencv,webcam
folks. I'm not entirely sure how should I send the encoded image over the UDP datagram. Once the UDP service is established, I'm running this loop: Server side: FrameCapture = cvCaptureFromCAM(-1); frameORG = cvQueryFrame(FrameCapture); small = cvCreateImage(cvSize(frameORG->width / 2, frameORG->height / 2), frameORG->depth, 3); while((cvWaitKey(40) & 0xFF) != ESC_KEY) {...

opencv after install characters look awkward [duplicate]

opencv
This question already has an answer here: opencv :: Multiple unwanted window with Garbage name 2 answers Good day I installed VS2013 on windows 8.1 x64 I was trying to install opencv and i had alot of problems the final error LNK1112: module machine type 'X86' conflicts with target...

How to call OpenCV's MatchTemplate method from C#

c#,opencv,image-processing,emgucv,opencvsharp
I'm trying to get the template's position on the image using OpenCVSharp library from NuGet. Here is the code I've wrote: var image = Cv.LoadImage("Image.png"); var template = Cv.LoadImage("Template.png"); var w = (image.Width - template.Width) + 1; var h = (image.Height - template.Height) + 1; IplImage result = new IplImage(w,...

UnsatisfiedLinkError while running on netbeans java project

java,opencv,netbeans
I'm tryng to build a little programm to capture picture from people and save them. What i'm tryng to do for now, is get the picture with a webcam using opencv library. As i'm quite beginner, i'm just tryng here to import opencv to my project to run some tutorials...

Back ground Subtraction class pros please answer

image,opencv,image-processing,background-subtraction,pixel-manipulation
Can someone define the class BackgroundSubtractorMOG2.What does history(argument for the BackgroundSubtractor class mean).Is some technique like code books available using BackgroundSubtractorMOG2 class?? Thanks in advance...

Face Recognition using c++ and opencv [closed]

c++,opencv
I want to compare between two faces using openCV , how can I do that ?

how can i know if the image is in RGB or BGR format?

java,opencv,image-processing,rgb,bgr
is there any way to know in advance if an image used as an input to a system is in RGB or BGR format? I am using opencv with java API and i would like to convert an input image into grayscale or Lab* color space, and in opencv you...

Using OpenCV in Swift iOS

ios,swift,opencv,image-processing
After adding the OpenCV 2 framework in my xcode project, I tried searching for samlpes or tutorials for integration with swift. Are there any good tutorials for the same?...

How to create rotated rectangular or polygonal ROI/mask?

c++,opencv,mask,threshold,roi
Let's say i have the following image: And my region of interest looks like this: And i want to have the following result: How can i achieve this knowing that the ROI is denoted by four points: Point pt1(129,9); Point pt2(284,108); Point pt3(223,205); Point pt4(67,106); ...

Creating a 25fps slow motion video from a 100fps GoPro .mp4 video with C++/OpenCV

c++,opencv,video,visual-studio-2013,slowmotion
I have a 100fps .mp4 GoPro video and I want to create from it a slow Motion one with 25fps. I'm trying since two days but to no avail. I could play the video, save a video from the GoPro's WiFi stream, but when I try to read the 100fps...

Camera calibration and conversion of coordinates(OpenCV)

c++,opencv,c++11,computer-vision
I am trying to map the 2D pixel coordinates in an image to real world 3D coordinates with respect to a fixed webcam. The calibration tutorial on the OpenCV page (http://docs.opencv.org/doc/tutorials/calib3d/camera_calibration/camera_calibration.html) has given me the following xml file: <?xml version="1.0"?> <opencv_storage> <calibration_Time>"Wed Jun 17 12:02:01 2015"</calibration_Time> <nrOfFrames>25</nrOfFrames> <image_Width>640</image_Width> <image_Height>480</image_Height>...

Extracting polygon given coordinates from an image using OpenCV

python,opencv,image-processing
I've a set of points like the following: <data:polygon> <data:point x="542" y="107"/> <data:point x="562" y="102"/> <data:point x="582" y="110"/> <data:point x="598" y="142"/> <data:point x="600" y="192"/> <data:point x="601" y="225"/> <data:point x="592" y="261"/> <data:point x="572" y="263"/> <data:point x="551" y="245"/> <data:point x="526" y="220"/> <data:point x="520" y="188"/> <data:point x="518" y="152"/> <data:point x="525" y="127"/> <data:point...

How to get pixel coordinates from Feature Matching

python,opencv,image-processing,matching,feature-detection
I need to get the list of the x and y coordinates of the pixels that feature matcher selects in the code provided. I'm using Python and OpenCV. Can anyone help me? img1=cv2.imread('DSC_0216.jpg',0) img2=cv2.imread('DSC_0217.jpg',0) orb=cv2.ORB(nfeatures=100000) kp1,des1=orb.detectAndCompute(img1,None) kp2,des2=orb.detectAndCompute(img2,None) img1kp=cv2.drawKeypoints(img1,kp1,color=(0,255,0),flags=0) img2kp=cv2.drawKeypoints(img2,kp2,color=(0,255,0),flags=0) cv2.imwrite('m_img1.jpg',img1kp) cv2.imwrite('m_img2.jpg',img2kp)...

OpenCV return keypoints coordinates and area from blob detection, Python

python,opencv
I followed a blob detection example (using cv2.SimpleBlobDetector) and successfully detected the blobs in my binary image. But then I don't know how to extract the coordinates and area of the keypoints. Here are the code for the blob detections: # I skipped the parameter setting part. blobParams = cv2.SimpleBlobDetector_Params()...

Visual Studio 2013 LINK : fatal error LNK1181: cannot open input file

c++,visual-studio,opencv,visual-c++,visual-studio-2013
I am using Visual Studio 2013. I'm trying to build some code given to me from my professor and I keep getting this error: LINK : fatal error LNK1181: cannot open input file 'C:\Users\manduchi\Documents\eyegaze\EyeGazeDemo..\Libraries\OpenCV\lib\opencv_core249.lib' However, on my computer opencv_core249.lib is located somewhere else. I've tried updating the linker directories to...

Must compile Opencv with Mingw in order to use in QT under Winodws?

qt,opencv,mingw
I've visit these blogs https://zahidhasan.wordpress.com/2014/08/19/qt-5-3-1-64-bit-mingw-windows/ How to link opencv in QtCreator and use Qt library http://www.cnblogs.com/grandyang/p/4328896.html All of them are using Mingw to compile Opencv through Cmake. If I want to use Opencv in QT, is compiling with Mingw the only way? I have this question because I already compiled...

Simple speed up of C++ OpenMP kernel

c++,opencv,openmp
I have never worked with OpenMP or optimization of C++, so all help is welcome. I'm probably doing some very stupid things that slow down the process drastically. It doesn't need to be the fastest, but I think some easy tricks will significantly speed it up. Anyone? Thanks a lot!...

Detecting face using haar-like cascade in opencv using c++

c++,opencv
I have been trying to execute the below code but couldn't compile it.I searched for error by masking some lines as comments.Finally I reached CascadeClassifier face_cascade;by removing all the other lines from face_cascade.load to rectangle(image,faces[i],Scalar(0,125,165),2,8,0); But I couldn't understand what the error is!Did I declare CascadeClassiier in a wrong way?...

OpenCV 3.0.0 Mat.push_back for vector line

c++,opencv,mat,opencv3.0
I want to procedurally build an OpenCV Mat line by line using the push_back function. #include <iostream> #include <stdbool.h> #include <opencv2/core.hpp> #include <opencv2/highgui.hpp> using namespace std; using namespace cv; int main(){ Mat matrix(1,3,CV_8UC1); vector<unsigned char> line(3,1); matrix.push_back(Mat(line,true).t()); return 0; } This returns the following error OpenCV Error: Assertion failed (DataType<_Tp>::type...

Extracting Points from Lines using OpenCV

c++,opencv
I am trying to extract points from a line on an image using openCV in C++ Language. The line is programmed to display on the image, but I need to know how do you extract points from line and input it into a text file?

OpenCV Individual Pixel Access

c++,opencv
I'm trying to learn OpenCV and have been going through various tutorials and books. I've ran into an odd problem. I have a 3 row, 3 column 3-channel matrix in OpenCV I named test. I filled it with dummy data like so: Mat test(3,3, CV_8UC3, Scalar(50,100,200)); When I print out...

java.lang.NoClassDefFoundError: org/opencv/core/Core - Java Servlet + OpenCV

java,opencv,servlets
I am trying to use opencv 2.4.9. in a Java Servlet with NetBeans, i have two files - the first one is a Servlet java file Login.java which is called by index.html , and the second one is CamCap.java a java file with all the opencv imports but this file...

best way to create a mat from a CIImage?

c++,xcode,osx,opencv,opencv3.0
I am using CIDetector to detect faces, then using OpenCV on the lower half of each face to detect the size of any smiles. I am using the below code to create the cv::mat which OpenCV can perform the detection on, as you can see the image goes through the...

eclipse: java.lang.UnsatisfiedLinkError

java,eclipse,opencv
I'm working on javacv project but every time I try to declare a matrix as below: Mat trainingData = new Mat(); I get this error: Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat()J at org.opencv.core.Mat.n_Mat(Native Method) at org.opencv.core.Mat.<init>(Mat.java:447) And when i search for a solution, i always found that i have to...

solvePnP: Obtaining the rotation translation matrix

c++,opencv,matrix,computer-vision,transform
I am trying to image coordinates to 3D coordinates. Using the solvePnP function (in C++)has given me 3X1 rotation matrix and 3X1 translation matrix. But isn't the [R|t] matrix supposed to be 3X4? Any help will be greatly appreciated!...

OpenCV findContours() complains if used with black-white image

python,opencv
I want to perform edge detection with the following code. However I get an error because of the image color depth. This error makes in my eyes no sense, as I convert the image properly to gray-scale image, and in a subsequent step to a black and white image, which...

How to find out what type to use for OpenCV .at function in C++?

c++,opencv
Is there a simple reliable way to find out what equivalent type I should use for the .at function for a Mat of a given CV type? For example, how can I tell that the blanks should be filled with ushort, float and Vec3b? Mat mat1(1, 2, CV_16UC1, 12345); std::cout...

many undefined functions in opencv 3.0.0 using visual studio 2013

c++,visual-studio,opencv,visual-studio-2013,opencv3.0
I have just started out to learn opencv but facing many issues. i have installed opencv and linked it to visual studio 2013. My first program which i copied from a video worked fine, which was #include <cstdio> #include <opencv2\opencv.hpp> void main() { std::cout << "OpenCV Version: " << CV_VERSION...

Convert cv::Mat to openni::VideoFrameRef

c++,opencv,kinect,openni
I have a kinect streaming data into a cv::Mat. I am trying to get some example code running that uses OpenNI. Can I convert my Mat into an OpenNI format image somehow? I just need the depth image, and after fighting with OpenNI for a long time, have given up...

Cmake errors: The CXX Compiler identification is unknown, The C compiler identification is unknown

c++,opencv,cmake,arm,cmake-gui
I'm trying to install OpenCV on Fedora 21 with a cross compiler for ARM processor. However, when i try to configure using Cmake 3.03, it gives the error: *The CXX compiler identification is unknown The C compiler identification is unknown Check for working CXX compiler: /opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-g++ Check for working CXX...

Why does openCV image stitching work for images loaded in project but not dynamically loaded images

ios,image,opencv,image-stitching,opencv-stitching
I have an application that stitches images using openCV and I save the images to my camera roll and to a location in the file system. When I pass those images in the file system as an array of UIImages in my file system, the stitching method does not work....

OpenCV Save a Mat as Binary (1-bit depth) TIFF

opencv,tiff,binary-image
Suppose we have a Mat after applying the OpenCv's Imgproc.adaptiveThreshold: Mat srcImage = ...; Mat binaryImage = new Mat(); Imgproc.adaptiveThreshold(srcImage, binaryImage, 255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C, Imgproc.THRESH_BINARY, THRESHOLD_BLOCK_SIZE, 10); When I save the binaryImage using Highgui.imwrite: boolean isOk = Highgui.imwrite("sample.tiff", binaryImage); Everything is ok except that output TIFF is not actually a binary...

Lab-image values on both of a and b axises exceeds the range

java,opencv,image-processing,colors,javacv
i converted a color image to Lab-color space, and when i displayed the values of the Lab-image, i found that the values of the pixels on the a-axis and b-axis are greater than 128!! while the values on the a-axis and b-axis should range from -128 to +128 please let...

Passing grayscale OpenCV image to an OpenGL texture

c++,opencv,opengl,glsl
I want to use a grayscale image generated in OpenCV in a GLSL shader. Based on the question on OpenCV image loading for OpenGL Texture, I've managed to come up with the code that passes RGB image to the shader: cv::Mat image; // ...acquire and process image somehow... //create and...

How to evenly distribute numbers 0 to n into m different containers

c++,opencv,math
I am trying to write an algorithm for a program to draw an even, vertical gradient across an image. I.e. I want change the pixel color from 0 to 255 along the m rows of an image, but cannot find a good generic algorithm to do so. I've tried to...

CV_32FC1 to bitmap

c++,winforms,opencv,bitmap
I've an image loaded in a Mat. From this, I calculate the DFT, so in a new Mat I've the DFT stored (both the real and img. parts). Since here, I aim to draw the magnitude of the DFT. I've achieved this already with OpenCV, by calculating it, take it...

Bandpass Filter in Python for Image Processing

python,image,opencv,image-processing,filtering
I have a noisy dataset (a stack of images) which films dim particles moving about some really bright artefacts (which are immobilized). I would like to somehow remove the immobilized artefacts from the images by applying some sort of bandpass filter wherein only pixels within a specific range are converted...

How to create thumbnails using opencv-python?

python,opencv,image-processing,python-imaging-library
I'm trying to downsample my image(using anti-aliasing) using Python-Pillow's im.thumbnail() method. My code looks like: MAXSIZE = 1024 im.thumbnail(MAXSIZE, Image.ANTIALIAS) Can you tell me some alternative in opencv-python to perform this re-sizing operation ?...

Kinectv2 normalizing depth values

c#,opencv,computer-vision,kinect,kinect-sdk
I am using Kinect v2 to capture the depth frames. I saw Kinect SDK 1.x codes in C++, they used this BYTE depth = 255 - (BYTE)(256*realDepth/0x0fff); I want to know, what is the purpose of this command and do I need to use this also for Kinect v2? If...

Is * sign in frameSize.height*frameSize.width*nmixtures*(2 + 2*nchannels) means pointer or multiplication?

c++,opencv
I'm never used C++ before, and I used OpenCV background subtraction MOG (Mixture of Gaussian) function in Python and I need to understand how the program works, the OpenCV program line 123 there's command bgmodel.create( 1, frameSize.height*frameSize.width*nmixtures*(2 + 2*nchannels), CV_32F );.. I found the .create function is to allocate new...

Estimating pose of one camera given another with known baseline

opencv,computer-vision
I am a beginner when it comes to computer vision so I apologize in advance. Basically, the idea I am trying to code is that given two cameras that can simulate a multiple baseline stereo system; I am trying to estimate the pose of one camera given the other. Looking...

Firewire 1394 camera with OpenCV

c++,opencv,camera,nvidia,firewire
I am trying to run face detection demo from OpenCV using firewire 1394 camera. While doing so I got the following error. Unable to stop the stream.: Bad file descriptor In capture ... VIDIOC_STREAMON: Inappropriate ioctl for device Unable to stop the stream.: Inappropriate ioctl for device Here is the...

Sending live video frame over network in python opencv

python,opencv,numpy
I'm trying to send live video frame that I catch with my camera to a server and process them. I'm usig opencv for image processing and python for the language. Here is my code client_cv.py import cv2 import numpy as np import socket import sys import pickle cap=cv2.VideoCapture(0) clientsocket=socket.socket(socket.AF_INET,socket.SOCK_STREAM) clientsocket.connect(('localhost',8089))...

How to limit float type Mat precision in OpenCV?

c++,opencv,matrix
I have a matrix of type CV_32FC1, and I want to limit its precision. For instance, it has value like this: [0.00021743798, 0.000174778698, 0.00011652464, 5.826234e-005, 1.561136e-005] But I want to limit its precision so that it will look like this (like in Matlab): [0.0002, 0.0002, 0.0001, 0.0001, 0.0000] I'm not...

how to use SIFT features for bag of words in opencv?

opencv,sift,multilabel-classification
I have read a lot of articles about implementing bag of words after taking sift features of an image, but I'm still confused what to do next. What do i specifically do? Thank you so much in advance for the guidance. This is the code that i have so far....

OpenCV 2.4.3 Download [on hold]

c++,opencv
Looking to learn OpenCV with C++, but all the tutorials I've found on youtube are with CV 2.4.3. On OpenCV's website, there is no 2.4.3 download link. Does anyone know why, or where I can find an alternative? Thanks...

OpenCV get coordinates of red-only rectangle area

c++,opencv,image-processing
I have the following output from red-only filtration done by the following algorithm: cv::Mat findColor(const cv::Mat & inputBGRimage, int rng=20) { // Make sure that your input image uses the channel order B, G, R (check not implemented). cv::Mat mt1, mt2; cv::Mat input = inputBGRimage.clone(); cv::Mat imageHSV; //(input.rows, input.cols, CV_8UC3);...

Opencv mlp Same Data Different Results

c++,opencv,machine-learning,neural-network,weight
Let Me simplify this question. If I run opencv MLP train and classify consecutively on the same data, I get different results. Meaning, if I put training a new mlp on the same train data and classifying on the same test data in a for loop, each iteration will give...

Haar Cascade classifier does not detect faces in simple frontal pictures

python,opencv,computer-vision
Trying to do some simple face detection using opencv + python using Haar Cascade Classifier. Below code perfectly detects faces in image1, image2 but fails to detect in image3 Kindly help me understand what are the reasons for non-detection of face in image3 import numpy as np import cv2 face_cascade...

OpenCV - Method 'knnMatch' could not be resolved

c++,opencv,include
I have just a little problem with the right resource. I am using opencv 2.4.8 and I couldn't find the right resource for knnMatch(). I tried the following which didn't work: #include "opencv2/core/core.hpp" #include <opencv2/nonfree/features2d.hpp> #include "opencv2/nonfree/nonfree.hpp" #include <opencv2/ml/ml.hpp> //#include "opencv2/features2d/features2d.hpp" //#include <opencv2/legacy/legacy.hpp> Can someone say me the right resource?...

Pass coordinates of 2D Numpy pixel array to distance function

python,opencv,numpy,pixel,euclidean-distance
I'm working on an image processing program with OpenCV and numpy. For most pixel operations, I'm able to avoid nested for loops by using np.vectorize(), but one of the functions I need to implement requires as a parameter the 'distance from center', or basically the coordinates of the point being...

OpenCV FAST corner detection SSE implementation walkthrough

c,performance,opencv,optimization,sse
Could someone help me understanding the SSE implementation of the FAST corner detection in OpenCV? I understand the algorithm but not the implementation. Could somebody walk me through the code? The code is long, so thank you in advance. I am using OpenCV 2.4.11 and the code goes like this:...

error using already compiled version of openCV

c++,c,linux,opencv
I've used the already compiled version of openCV for Raspberry Pi. link for anyone who is interested After trying to compile using this command line g++ test3.cpp -o test3 -I/usr/local/include/ -lraspicam -lraspicam_cv -L/opt/vc/lib -lmmal -lmmal_core -lmmal_util -I/usr/include -lopencv_core -lopencv_highgui -lopencv_imgproc -lwiringPi -lpthread I get the following error lines. //usr/local/lib/libopencv_stitching.so.2.4: undefined...

Surface normal on depth image

c++,opencv,computer-vision
How to estimate the surface normal of point I(i,j) on a depth image (pixel value in mm) without using Point Cloud Library(PCL)? I've gone through (1), (2), and (3) but I'm looking for a simple estimation of surface normal on each pixel with C++ standard library or openCV. ...

Dividing main function into other functions in opencv using c++

c++,opencv
I am learning opencv using c++. As I don't have any background knowledge in c++.I am learning it parallel with opencv. Here is my doubt.My main program is very big.So,I want to divide it into small functions and call them whenever necessary in a loop using conditional statements.I have searched...

Error for cv::FileStorage in JNI

android,c++,opencv,android-ndk,file-storage
I am getting errors while compiling my native.cpp file in Eclipse ADT/NDK. While compiling the following lines of code FileStorage storage(nativepath, FileStorage::WRITE); storage << "img" << mat; storage.release(); The errors are D:/androidworkspace/Augmented-Reality//obj/local/arm64-v8a/objs/ndksetup/native.o: In function Java_com_shahrukh_AugmentedReality_CAMShiftDetection_savemat(_JNIEnv*, _jobject*, long long, _jstring*)': D:\androidworkspace\Augmented-Reality/jni/native.cpp:14: undefined reference...

'MSize' is not a member of cv::Mat

c++,eclipse,opencv,mat
I'm trying to run this repo for curiosity: https://github.com/jzeimen/PuzzleSolver/tree/master/PuzzleSolver Eclipse throws the title error "'MSize' is not a member of cv::Mat' whenever I try to run the following line of code from PuzzleDisjointSet.cpp: cv::Mat::MSize size_of_a = sets[rep_a].locations.size; Where locations is defined like so: struct forest{ cv::Mat_<int> locations; cv::Mat_<int> rotations; int...

A better way to add text to ca cv::Mat than cv::putText()?

opencv
I want to put some text on a cv::Mat, but cv::putText() is not flexible enough for me. Alginment I need to put labels of variable length at several pixel positions which are known at runtime, but since cv::putText() places the origin of the output always on the left, my text...

OpenCV algorithm of contours searching and creation of bounding rectagle

python,algorithm,opencv,computer-vision,contour
Hi to the whole programmers society! It has become habitual to me to get acknowledgement of every algorithm I employ in projects. And not long ago I implemented OpenCV library methods to detect contours within input frame as well as to draw bounding rectangle around detected object. So I came...

copying a 24x24 image into a 28x28 array of zeros

python,opencv,numpy
Hi I want to copy a random portion of a 28x28 matrix and then use the resulting 24x24 matrix to be inserted into a 28x28 matrix image = image.reshape(28, 28) getx = random.randint(0,4) gety = random.randint(0,4) # get a 24 x 24 tile from a random location in img blank_image...

Fastest way to copy some rows from one matrix to another in OpenCV

c++,matlab,opencv,matrix
I have a [32678 x 10] matrix (w2c) and I want to copy 24700 rows of it to another matrix(out). I have the index of the rows to be copied in a vector(index). For doing this in matlab I do: out = w2c(index_im,:); It takes approximately 0.002622 seconds. In OpenCV:...

Android edit images on the fly

android,opencv,bitmap,android-bitmap,opencv4android
It seems that in Android there are no "easy" libraries for editing and save pictures, neither free or with licenses). Aviary is no longer available. I have to implement an app for Taking picture, edite with some effects on the fly (Vignetting contrast, brightness...), add some text and save. A...

Error : Cmake can't generate openCV

opencv,cmake,codeblocks
I am trying to instal opencv C++ with codeBlocks in Windows 8 by following this http://kevinhughes.ca/tutorials/opencv-install-on-windows-with-codeblocks-and-mingw/ but I am blocked in step 4.when I try to generate Cmake I have this Error : CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not...

Is there a way to prevent rounding in opencv matrix divison

c++,opencv
I have an integer matrix and I want to perform an integer division on it. But opencv always rounds the result. I know I can divide each element manually but I want to know is there a better way for this or not? Mat c = (Mat_ <int> (1,3) <<...

How to detect squares in video with OpenCV?

c++,c,opencv,video
So I combined squares.cpp with cvBoundingRect.cpp code to detect squares in video. I therefore, had to convert from IplImage to Mat type so that findSquares and drawSquares methods could run (By using cvarrToMat function). But unfortunately, after successful compilation I get this error when running: OpenCV Error: Assertion failed (j...

Reducing the size/resolution of a saved video

python,opencv
I'm new to OpenCV and I'm trying to figure this out. I have a .mp4 file saved on disk that I streamed from a webcam. Now I need to produce a lower res version of the video for upload to a web server (this idea is that a low-res preview...

conversion between Mat and Mat1b/Mat3b

c++,opencv,image-processing,mat
I want to match my code into a given interface. Inside my class OperateImage in all methods I use cv::Mat format. When putting it in SubMain function which uses cv::Mat3b and returns cv::Mat1b it does not work. How can I change it so that I can use my written class?...

opencv window not refreshing at mouse callback

c++,opencv
I am trying to draw with mouse move in an opencv window. But when I draw, nothing draws on the window. When I try to close the window from the cross in the topleft(ubuntu), it opens a new window which it should be as I haven't pressed escape, and in...

Heap Corruption using cv::FlannBasedMatcher and std::vector

c++,opencv,vector,feature-extraction,heap-corruption
I am developing a breast imaging features for object recognition, using FlannBasedMatcher to compute spatial histograms. Mat ComputeSpatialHistogram(Mat features, Mat vocabulary, int* region_index, int level, Ptr<DescriptorMatcher> flann_matcher) { int vocab_size = vocabulary.rows; Mat descriptor = Mat::zeros(1, vocab_size*my_pow(4, level), CV_32FC1); if (features.rows > 0) { vector<DMatch> matches; flann_matcher->match(features, matches); int word_idx,...

OpenCV & Python: quickly superimpose mask over image without overflow

python,opencv,numpy,mask
I'd like to superimpose a binary mask over a color image, such that where the mask is "on", the pixel value changes by an amount that I can set. The result should look like this: I am using OpenCV 2.4 and Python 2.7.6. I have a way that works well,...

How to convert a 3D vector to a cv::Mat

c++,opencv
I am trying to fill up an OpenCV Mat (float) from a 3D vector of floats (vGraph1). However, the resulting OpenCV Mat (test) is not correctly filled, i.e. only the first column is filled with correct values while the rest are junk values (-4.32e+08). I confirmed the error by writting...

convert unsigned short mat to vector in opencv

c++,opencv,vector,mat
I load a depth image in opencv with cv::Mat depth = cv::imread("blabla.png",CV_LOAD_IMAGE_UNCHANGED); then get a subimage of it with cv::Mat sub_image= depth(cv::Rect( roi_x,roi_y,roi_size,roi_size)).clone(); now I want to convert that sub_image into a vector I try with std::vector<uchar> array; array.assign(sub_image.datastart,sub_image.dataend); that found here in StackOverflow in a similar question but it...

OpenCV / Image Processing techniques to find the centers of bright spots in an image

python,opencv,image-processing,feature-detection
I'm currently doing a project based on the methodology described in this paper: Camera calibration from a single night sky image As a beginner in computer vision, I do not quite understand how I can implement the method used in the paper to find the centre of all the bright...

Sending a Mat object over socket from Java to Java

java,sockets,opencv,mat
I understand Sockets over Java and sending Int,String,bytes etc over it. What i just want to know is that is there a way to decode a Mat object to byte array and then send it over java socket and then retrieve back the Mat object from the byte received? Till...