I got this problem when trying to compile opencv using Cmake and mingw.
for Cmake:
sourcecode is located in "C:\CPP Libraries\OpenCV-2.4.13\opencv\sources"
where the binaries are goint to be build is in: "C:/CPP Libraries/OpenCV-2.4.13/opencv/build/x64/mingw"
I've already used Cmake to generate the makefile.
when i run the makefile:
C:\CPP Libraries\OpenCV-2.4.13\opencv\build\x64\mingw>mingw32-make
this is the output that I get after 31%
[ 31%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_w32.cpp.obj
C:\CPP Libraries\OpenCV-2.4.13\opencv\sources\modules\highgui\src\window_w32.cpp: In function 'int icvCreateTrackbar(const char*, const char*, int*, int, CvTrackbarCallback, CvTrackbarCallback2, void*)':
C:\CPP Libraries\OpenCV-2.4.13\opencv\sources\modules\highgui\src\window_w32.cpp:1853:81: error: 'BTNS_AUTOSIZE' was not declared in this scope
WS_CHILD | CCS_TOP | TBSTYLE_WRAPABLE | BTNS_AUTOSIZE | BTNS_BUTTON,
^
C:\CPP Libraries\OpenCV-2.4.13\opencv\sources\modules\highgui\src\window_w32.cpp:1853:97: error: 'BTNS_BUTTON' was not declared in this scope
WS_CHILD | CCS_TOP | TBSTYLE_WRAPABLE | BTNS_AUTOSIZE | BTNS_BUTTON,
^
modules\highgui\CMakeFiles\opencv_highgui.dir\build.make:187: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_w32.cpp.obj' failed
mingw32-make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_w32.cpp.obj] Error 1
CMakeFiles\Makefile2:2203: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/all' failed
mingw32-make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
Makefile:159: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
Does anyone knows a solution, because i have no clue about this one.
↧
Problem compiling OpenCV 2.4.13 with Cmake and MinGW
↧
Cropping a face and removing the background?
After some research I found that OpenCV is going to by my friend all my way through finishing this project. I want to crop a human's face from an image, remove the background and save the result. Since a picture is worth a thousand words, here's what I want to achieve:
[![Comparison][1]][1]
Sorry for the cheap image editing. How can I accomplish this with OpenCV or without OpenCV? I'm going to use Arduino too if anyone has something to do with this :P.
[1]: http://i.stack.imgur.com/okLpG.png
↧
↧
Giving error malloc(): memory corruption: and Segementation fault
Pose.h
#ifndef POSE_H
#define POSE_H
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/core/core.hpp"
#include
#include
using namespace std;
using namespace cv;
class Pose
{
public:
Pose();
double* contour_detection(Mat threshold,Mat src);
double* pose_estimation(const std::vector&objectPoints,const std::vector&imagePoints);
private:
vector objectPoints ;
Mat cameraIntrinsicParams ;
Mat distCoeffs;
int index[100];
double area_array[100];
};
#endif // POSE_H
Pose.cpp
#include "Pose.h"
Pose::Pose()
{
objectPoints.push_back(cv::Point3f(-50.0f,-50.0f,0.0f));
objectPoints.push_back(cv::Point3f(-50.0f,50.0f,0.0f));
objectPoints.push_back(cv::Point3f(50.0f,50.0f,0.0f));
objectPoints.push_back(cv::Point3f(50.0f,-50.0f,0.0f));
cameraIntrinsicParams=Mat(Size(3,3),CV_32FC1);
cameraIntrinsicParams.at(0,0)= 694.507824f;
cameraIntrinsicParams.at(0,1)= 0 ;
cameraIntrinsicParams.at(0,2)= 329.707540f;//304.729528f;
cameraIntrinsicParams.at(1,0)= 0 ;
cameraIntrinsicParams.at(1,1)= 694.579263f;
cameraIntrinsicParams.at(1,2)= 260.350615f;//235.217420f;
cameraIntrinsicParams.at(2,0)= 0 ;
cameraIntrinsicParams.at(2,1)= 0 ;
cameraIntrinsicParams.at(2,2)= 1 ;
distCoeffs=Mat(Size(5,1),CV_32FC1);
distCoeffs.at(0,0)=0.015950f;
distCoeffs.at(1,0)=-0.224494f;
distCoeffs.at(2,0)=0.002544f;
distCoeffs.at(3,0)=0.000194f;
distCoeffs.at(3,0)=0.00f;
}
double* Pose::contour_detection(Mat threshold, Mat src)
{
int flag =0;
double largest_area=0.0;
int largest_contour_index=0;
int lowThreshold;
int ratio=3;
int kernel_size=3;
int const max_lowThreshold = 100;
double *location;
static double check[3]={0.0,0.0,0.0};
int j=0;
//int index[100];
//double area_array[100];
//double *condition;
Mat dst(src.rows,src.cols,CV_8UC1,Scalar::all(0));
Rect boundRect;
RotatedRect box;
vectorPoints ;
vector< vector> contours; // Vector for storing contour
vector hierarchy;
Mat detected_edges;
blur(threshold, detected_edges, Size(3,3) );
/// Canny detector
Canny( detected_edges, detected_edges, lowThreshold, lowThreshold*ratio, kernel_size );
vector< vector> contours0;
findContours( detected_edges, contours0, hierarchy,CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE ); // Find the contours in the image
contours.resize(contours0.size());
std::vector imagePoints;
std::vector preciseCorners(4);
int k;
for( k=0; k < contours0.size(); k++ )
{
cout<<"size"<1)
{
cout<<"5"<largest_area)
{
largest_area=area_array[i];
largest_contour_index=i; //Store the index of largest contour
}
}
}
if(j>1)
{
for( int i = 0; i=3.0 || ratio<=5.0)
{
for (int c=0;c<4;c++)
{
preciseCorners[c] = contours[index[largest_contour_index]][c];
}
cv::cornerSubPix(threshold, preciseCorners, cvSize(5,5),cvSize(-1,-1), TermCriteria( CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 40, 0.001 ));
// cv::cornerSubPix(threshold, preciseCorners, cvSize(5,5),cvSize(-1,-1), cvTermCriteria(CV_TERMCRIT_ITER,30,0.1));
for (int c=0;c<4;c++)
{
contours[index[largest_contour_index]][c] = preciseCorners[c];
}
imagePoints.push_back(Point2f(contours[index[largest_contour_index]][0].x,contours[index[largest_contour_index]][0].y));
imagePoints.push_back(Point2f(contours[index[largest_contour_index]][1].x,contours[index[largest_contour_index]][1].y));
imagePoints.push_back(Point2f(contours[index[largest_contour_index]][2].x,contours[index[largest_contour_index]][2].y));
imagePoints.push_back(Point2f(contours[index[largest_contour_index]][3].x,contours[index[largest_contour_index]][3].y));
Point P1=contours[index[largest_contour_index]][0];
Point P2=contours[index[largest_contour_index]][1];
Point P3=contours[index[largest_contour_index]][2];
Point P4=contours[index[largest_contour_index]][3];
line(src,P1,P2, Scalar(0,255,0),1,CV_AA,0);
line(src,P2,P3, Scalar(0,255,0),1,CV_AA,0);
line(src,P3,P4, Scalar(0,255,0),1,CV_AA,0);
line(src,P4,P1, Scalar(0,255,0),1,CV_AA,0);
location=pose_estimation(objectPoints,imagePoints);
return location;
}
}
}
return check;
}
pose_estimaton function
double* Pose::pose_estimation(const std::vector&objectPoints,const std::vector&imagePoints)
{
static double position[4];
Mat rvec,tvec,inliers;
//rvec=Mat::zeros(3,1,CV_64FC1);
//tvec=Mat::zeros(3,1,CV_64FC1);
//int flags=0;
bool useExtrinsicGuess =false;
int method = CV_ITERATIVE ;
cv::solvePnP(objectPoints,imagePoints, cameraIntrinsicParams, distCoeffs,rvec, tvec,useExtrinsicGuess,method);
Mat distant=Mat(Size(3,3),CV_64FC1);
Mat jacobian=Mat(Size(3,1),CV_32FC1);
Rodrigues(rvec,distant,jacobian);
Mat J;
vector p(4);
projectPoints(objectPoints,rvec,tvec, cameraIntrinsicParams, distCoeffs, p, J);
float sum = 0.;
for (size_t i = 0; i (0,0);
position[1]=T.at(1,0);
position[2]=T.at(2,0);
//}
return position;
}
↧
Using OpenCV's pca write and read for saving PCA data
I am using OpenCV's function for PCA analysis. I want to save and read back the PCA structure using the provided functions. The PCA analysis part is OK, and the function serializes the object to the output file OK. The problem is I cannot read back the serialized object. My code is as follows,
from the main function:
Mat_ C = (Mat_(2,6) << 1, 0, 3, 2, 1, 5, 6, 2, 0, 4, 0, 9);
doPCA(vec);
The doPCA function:
string file_name = "/media/femkha/HDB_FemkhaAcer/images2/cplus/pca_data";
const int MAX_COMPONENTS = 2;
{
FileStorage fs(file_name,FileStorage::WRITE);
PCA pca(vec,Mat(),PCA::DATA_AS_ROW,MAX_COMPONENTS);
pca.write(fs);
fs.release();
}
{
FileStorage fs2;
fs2.open(file_name,FileStorage::READ);
FileNode fn = fs2["PCA"];
}
The generated file is as follows:

%YAML:1.0
name: PCA
vectors: !!opencv-matrix
rows: 2
cols: 6
dt: d
data: [ 6.5094455490411940e-01, 2.6037782196164777e-01,
-3.9056673294247168e-01, 2.6037782196164777e-01,
-1.3018891098082389e-01, 5.2075564392329554e-01, 0., 0., 0., 0.,
0., 0. ]
values: !!opencv-matrix
rows: 2
cols: 1
dt: d
data: [ 1.4750000000000000e+01, 0. ]
mean: !!opencv-matrix
rows: 1
cols: 6
dt: d
data: [ 3.5000000000000000e+00, 1., 1.5000000000000000e+00, 3.,
5.0000000000000000e-01, 7. ]
↧
OpenCV 2.4.13 imshow() slow on OS X 10.11.6 (Xcode/C++)
I'm trying to do a simple video playback using OpenCV on OS X 10.11.6, but the performance of imshow() is very bad. I'm getting around 1 fps out of the video, no matter the waitKey() parameter value.
The crazy thing is: I have windows 7 as a VMWare Virtual Machine running on this machine and if I compile and run exactly the same code on this virtualised Windows (running inside the same OS that has bad performance), I get the full frame rate expected (30 FPS). Which means that this is not related to the memory or processing power of my machine (i7, 2.5GHZ, 16GB RAM).
This is the code I'm running
#include
using namespace cv;
int main(int argc, const char * argv[]) {
VideoCapture cap("/myvideo.mp4");
if(!cap.isOpened())
return -1;
Mat edges;
namedWindow("edges",1);
for(;;)
{
Mat frame;
cap >> frame;
imshow("edges", frame);
if(waitKey(30) >= 0) break;
}
return 0;
}
I've ported this code to python (using the official OpenCV port of python) and the problem persisted. If I run the same python code on this virtualised windows, I get the expected frame rate (30 FPS).
I've read this could be related to VSYNC, but I could not find a way to disable it and test. How can it run faster on a virtualised windows than on the host OS?!
Help is greatly appreciated.
Thank you.
BurningFuses
↧
↧
OpenCV source make error: OpenCV/modules/features2d/src/matchers.cpp:47:23: fatal error: Eigen/Array: No such file or directory
Hi,
Am using OpenCV3.1,Python2.7.
At sudo make of opencv source cloned from git rep, below log excerpt: (Kindly guide. Thanks in advance).
[ 77%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/keypoint.cpp.o
[ 77%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/main.cpp.o
[ 77%] Building CXX object modules/features2d/CMakeFiles/opencv_features2d.dir/src/matchers.cpp.o
/media/bhargav/Bhargav_WD1/temp_dir/home_bhargav/OpenCV/modules/features2d/src/matchers.cpp:47:23: fatal error: Eigen/Array: No such file or directory
compilation terminated.
modules/features2d/CMakeFiles/opencv_features2d.dir/build.make:552: recipe for target 'modules/features2d/CMakeFiles/opencv_features2d.dir/src/matchers.cpp.o' failed
make[2]: *** [modules/features2d/CMakeFiles/opencv_features2d.dir/src/matchers.cpp.o] Error 1
CMakeFiles/Makefile2:5821: recipe for target 'modules/features2d/CMakeFiles/opencv_features2d.dir/all' failed
make[1]: *** [modules/features2d/CMakeFiles/opencv_features2d.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2
↧
OpenCV FaceRec problem
Hey guys,
I'm using OpenCV Version 3.1.
I'm trying to use the LBPHFace Class (http://docs.opencv.org/trunk/df/d25/classcv_1_1face_1_1LBPHFaceRecognizer.html)
But it seems that im doing something wrong. When using LBPHModel->setThreshold(0.0) or LBPHModel->get histograms() i get a error telling me class cv::face::FaceRecognizer' has no member named 'setThreshod or getHsotgrams' . The code compiles and work if i dont use any of these functions.
#include "opencv2/core.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/face.hpp"
Ptr LBPHModel;
void LBPHLearning(holdingFaces holding){
LBPHModel = createLBPHFaceRecognizer(8,1,8,8);
LBPHModel->setThreshold(0.0);
LBPHModel->train(holding.images, holding.labels);
vector histograms = LBPHModel->getHistograms();
cout << "Size of the histograms: " << histograms[0].total() << endl;}
Thanks for your help in advance
↧
Is anyone know how to use opencv 3.1 in eclipse ide? (windows 64bit) ive searching for days now and still cant figure out how. Ive tried some methods but when I run the "mingw32-make" i always got errors.
Is anyone know how to use opencv 3.1 in eclipse ide? (windows 64bit) ive searching for days now and still cant figure out how. Ive tried this method (http://cookyourpc.blogspot.com/2015/08/setting-up-opencv-on-windows-with.html) but when I run the "mingw32-make" part i always got errors.
C:\opencv\sources\modules\core\src\parallel.cpp: In function 'int cv::getThreadNum()':
C:\opencv\sources\modules\core\src\parallel.cpp:457:45: error: 'pthread_self' was not declared in this scope
return (int)(size_t)(void*)pthread_self(); // no zero-based indexing
^
modules\core\CMakeFiles\opencv_core.dir\build.make:965: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/src/parallel.cpp.obj' failed
mingw32-make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/parallel.cpp.obj] Error 1
CMakeFiles\Makefile2:1468: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed
mingw32-make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
Makefile:159: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
**even i apply this**

↧
How to detect vehicle in opencv 3.1? Im using C++
I used this code but it detects many objects in the video:
using namespace cv;
using namespace std;
int main()
{
//global variables
Mat frame; //current frame
Mat back;
Mat fore, fMOG2, fKNN;
Mat resizeF;
Mat fgMaskMOG; //fg mask generated by MOG method
String stat= "Unoccupied";
Ptr pMOG; //MOG Background subtractor
pMOG = createBackgroundSubtractorMOG2();
pMOG->setNMixtures(3);
pMOG->setDetectShadows(0);
Ptr pKNN;
pKNN = createBackgroundSubtractorKNN();
pKNN->setDetectShadows(0);
//rect
//int largest_area=0;
//int largest_contour_index =0;
vector> contours;
vector hierarchy;
VideoCapture stream1(0); //0 is the id of video device.0 if you have only one camera
while(1){
Mat cameraFrame, cont, thresholds;
if(!(stream1.read(frame))) //get one frame form video
break;
pMOG->apply(frame, fore);
pKNN->apply(frame, fKNN);
pMOG->getBackgroundImage(back);
erode(fore, fore, Mat());
dilate(fore, fore, Mat());
//working con
//findContours(fore, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
//drawContours(frame, contours, -1, Scalar(0,0,255),2);
//contour
//vector hierarchy;
//findContours(frame, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0)); //detect contours
findContours(fore, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); //working_on
vector> contours_poly(contours.size());
vector bounding_rect(contours.size());
/*
for(int i =0; i100){
approxPolyDP(Mat(contours[i]),contours_poly[i],3,true);
bounding_rect[i] = boundingRect(Mat(contours_poly[i]));
}
} */
for(int i=0; i < contours.size(); i++){
double a= contourArea(contours[i], false);
//set the area size for which the program detects the object as vehicle
if(a>500){
approxPolyDP(Mat(contours[i]),contours_poly[i],3,true);
bounding_rect[i] = boundingRect(Mat(contours_poly[i]));
//largest_area=a;
//largest_contour_index=i;
//bounding_rect=boundingRect(contours[i]);
rectangle(frame, bounding_rect[i].tl(), bounding_rect[i].br(),Scalar(0,255,0),1,8,0);
stat = "Occupied";
}
else{
stat = "Unoccupied";
}
}
Scalar color(255,255,255);
//drawContours( frame, contours,largest_contour_index, color, CV_FILLED, 8, hierarchy );
//drawContours(frame, contours, -1, Scalar(0,0,255),2); //working
//rectangle(frame, bounding_rect, Scalar(0,255,0),1,8,0);
putText(frame, "Lot Status: "+stat, Point(10,20), FONT_HERSHEY_SIMPLEX, 0.5,(0,0,255),2,8);
imshow("Origin", frame);
imshow("MOG2", fore);
//imshow("KNN", fKNN);
//imshow("contour", frame_dupe);
if (waitKey(30) >= 0)
break;
}
}
↧
↧
Speed of filter2d vs. matchTemplate
For educational purposes I'm trying to understand following relation:
I'm applying a blur kernel (32x32) on
an image (500x667 Grayscale, 8 bit
for a single channel) which takes
approx. 107ms using cv::filter2d.
When however a template is being
matched on the same image with size
32x32, the call for matchTemplate (CV_TM_SQDIFF)
just takes 14ms.
Why is there such a huge difference in processing time? The documentation states, that starting with a kernel size of 11 x 11 filter2d will apply the kernel in the frequency domain which should speed things up. But the documentation also states that filter2d is computing the correlation instead of the convolution. So aren't both methods computing similar things?
↧
Deskew Text with OpenCV and Python
Hello, i'm new with OpenCV and i want to deskew an image that have a skew text:

First i read the image in GrayScale and Binarize it, then i try to do [this](http://opencvpython.blogspot.com.ar/2012/06/contours-2-brotherhood.html): import cv2 import numpy as np img = cv2.imread('m20.jpg',0) ret,byw = cv2.threshold(img,127,255,cv2.THRESH_BINARY_INV) _, contours, hierarchy = cv2.findContours(byw.copy(), cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) cnt = contours[0] draw = cv2.cvtColor(byw, cv2.COLOR_GRAY2BGR) rect = cv2.minAreaRect(cnt) box = cv2.boxPoints(rect) box = np.int0(box) cv2.drawContours(draw, [box], 0, (0, 255, 0), 2) But doesn't work beacause findContours() expect to receive an image with a body shape. Other way that i try is to translate this code of c++: // Read image Mat3b img = imread("path_to_image"); // Binarize image. Text is white, background is black Mat1b bin; cvtColor(img, bin, COLOR_BGR2GRAY); bin = bin < 200; // Find all white pixels vector pts;
findNonZero(bin, pts);
// Get rotated rect of white pixels
RotatedRect box = minAreaRect(pts);
if (box.size.width > box.size.height)
{
swap(box.size.width, box.size.height);
box.angle += 90.f;
}
Point2f vertices[4];
box.points(vertices);
for (int i = 0; i < 4; ++i)
{
line(img, vertices[i], vertices[(i + 1) % 4], Scalar(0, 255, 0));
}
// Rotate the image according to the found angle
Mat1b rotated;
Mat M = getRotationMatrix2D(box.center, box.angle, 1.0);
warpAffine(bin, rotated, M, bin.size());
And i have this:
draw = cv2.cvtColor(byw, cv2.COLOR_GRAY2BGR)
data = np.array(byw)
subzero = np.nonzero(data)
subuno = np.reshape(subzero,(17345,2)) # this is because cv2.minAreaRect() receives a Nx2 numpy
rect = cv2.minAreaRect(subuno)
box = cv2.boxPoints(rect)
box = np.int0(box)
cv2.drawContours(draw,[box],0,(0,255,0),2)
But then again the result it's not the expected:

Also occurs to me that might try to make the 'for' like in C++ but i don't know how to obtain the vertices from the 'box = cv2.boxPoints(rect)'. Please help!
First i read the image in GrayScale and Binarize it, then i try to do [this](http://opencvpython.blogspot.com.ar/2012/06/contours-2-brotherhood.html): import cv2 import numpy as np img = cv2.imread('m20.jpg',0) ret,byw = cv2.threshold(img,127,255,cv2.THRESH_BINARY_INV) _, contours, hierarchy = cv2.findContours(byw.copy(), cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) cnt = contours[0] draw = cv2.cvtColor(byw, cv2.COLOR_GRAY2BGR) rect = cv2.minAreaRect(cnt) box = cv2.boxPoints(rect) box = np.int0(box) cv2.drawContours(draw, [box], 0, (0, 255, 0), 2) But doesn't work beacause findContours() expect to receive an image with a body shape. Other way that i try is to translate this code of c++: // Read image Mat3b img = imread("path_to_image"); // Binarize image. Text is white, background is black Mat1b bin; cvtColor(img, bin, COLOR_BGR2GRAY); bin = bin < 200; // Find all white pixels vector
Also occurs to me that might try to make the 'for' like in C++ but i don't know how to obtain the vertices from the 'box = cv2.boxPoints(rect)'. Please help!
↧
Getting ORB descriptor values bit by bit
Hello!
**Context:** I am re-implementing the kmeans algorithm into a kmajority algorithm for binary descriptors, like ORB, based on hamming distances, [inspired by this paper](http://imagelab.ing.unimore.it/imagelab/pubblicazioni/2013ElectronicImaging.pdf). This requires, for every binary descriptor in a cluster, to make each bit position of each descriptor "vote" for either 0 or 1 for the final value of that position in the cluster center.
Descriptor 1: 0 0 0 0 1 0 1 0 ...
Descriptor 2: 1 0 1 0 1 0 1 0 ...
Descriptor 3: 1 0 0 0 1 0 0 0 ...
---------------------------------
Center : 1 0 0 0 1 0 1 0 ... <-- after majority vote for each bit
**Question:** ORB descriptors are stored in their mats as uchar, not bits. They are stored in a Mat of N rows (1 row per descriptor) and 32 columns (32 uchar for 256 bits). Obviously, I'm not interested in uchars, it's the bits I want. Therefore, is requesting the rows with:
bool* descriptor = myMat .ptr(rowIndex)
... the right approach if I want to iterate over a descriptor bit by bit instead of uchar by uchar? (I'm pretty unfamiliar with C++).
↧
distance measurement from camera to object?
I am working on a project to localize a robot, where in I need to determine the distance of the object from the camera. I've done a lot of research regarding this, but its a little out of my scope. I am using a single camera as I cannot afford a stereo camera :P I am working on Code Blocks as my platform. I would be really glad if someone could help me code this in c++.
↧
↧
Fatal signal 11 (SIGSEGV) in Android 6.0
**What I do:**
1.I Write the face detection in opencv c++ and call from android using wrapper.
2.I used android native camera and pass image(Mat) to the detection method(detection method is shown below)
3.Its working in android 4.0 to android 5.1 but while running in android 6.0, the application crashes
4.I added LOGD inside the c++ source code to find exactly where the crash happen.
5.Crashing happening at always at the end of the detection method in Android 6.0
6.Sample Code
CascadeClassifier cascade;
Rect detection(Mat& image)
{
LOGD("face1");
vector val;
Mat im(image.size(),CV_8UC1);
if(image.channels()==3)
{
cvtColor(image,im,COLOR_BGR2GRAY);
}
else
{
image.copyTo(im);
}
LOGD("face2");
cascade.detectMultiScale(im, val, 1.1,2,CASCADE_FIND_BIGGEST_OBJECT,Size(image.cols/3,image.rows/3));
LOGD("face3");
if(val.size()==0)
{
return Rect(0,0,0,0);
}
LOGD("face4");
return val[0];
}
7.Calling method in c++
Rect ROI=detection(image);
LOGD("val1: %d",ROI.x);
LOGD("val2: %d",ROI.y);
LOGD("val3: %d",ROI.width);
LOGD("val4: %d",ROI.height);
8.Android logcat message
When not giving face to camera it show in logcat like this
09-21 18:25:52.612 20436 20615 D qualitycheck: quality1
09-21 18:25:52.612 20436 20615 D qualitycheck: quality3
09-21 18:25:52.612 20436 20615 D qualitycheck: quality4
09-21 18:25:52.612 20436 20615 D qualitycheck: face1
09-21 18:25:52.622 20436 20615 D qualitycheck: face2
09-21 18:25:52.642 20436 20615 D qualitycheck: face3
09-21 18:25:52.642 20436 20615 D qualitycheck: quality27
09-21 18:25:52.642 20436 20615 D qualitycheck: res: 0
09-21 18:25:52.642 20436 20615 D qualitycheck: res1: 0
09-21 18:25:52.642 20436 20615 D qualitycheck: res2: 0
09-21 18:25:52.642 20436 20615 D qualitycheck: res3: 0
09-21 18:25:52.642 20436 20615 D qualitycheck: quality28
09-21 18:25:52.642 20436 20615 D qualitycheck: quality18
09-21 18:25:52.642 20436 20615 I QualityCheck : 1000
When giving face to camera it show in logcat like this
09-21 18:25:57.662 20436 20615 D qualitycheck: quality1
09-21 18:25:57.662 20436 20615 D qualitycheck: quality3
09-21 18:25:57.662 20436 20615 D qualitycheck: quality4
09-21 18:25:57.662 20436 20615 D qualitycheck: face1
09-21 18:25:57.662 20436 20615 D qualitycheck: face2
09-21 18:25:57.702 20436 20615 D qualitycheck: face3
09-21 18:25:57.702 20436 20615 D qualitycheck: face4
then application crashes
9.The log "face4" is shown ,but its not returning in detection method ,while running in android 6.0.
please help me to solve this issue.
Detailed log - https://s3.amazonaws.com/uploads.hipchat.com/140263/1400779/kS4OjMvPGa5d1zy/logcat.txt
↧
Accessing the Value for each Pixel of an Output Array of phase()
I want to make an Matrix which holds the Orientation value of each pixel in a image. I need it for methods I want to use on the source image later on. The Code I have for this at the moment looks like this:
#include
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
Mat src; Mat dst; Mat tmp;
void orientationMap(const cv::Mat& ori, double thresh = 1.0){
int i, j;
int** hist = 0;
hist = new int*[15];
for( i = 0; i < ori.rows; i++){
hist[i] = new int[15];
for( j = 0; j < ori.cols; j++){
int pixelValue = (int)ori.at(i,j);
cout << pixelValue << endl;
}
}
}
int main(int argc, const char * argv[]) {
String imgName("example.jpg");
src = imread(imgName,0);
Mat patch = src(Rect(30,30,15,15));
Mat Sx;
Sobel(patch, Sx, CV_32F, 1,0,3);
Mat Sy;
Sobel(patch, Sy, CV_32F, 0, 1, 3);
Mat mag, ori;
magnitude(Sx, Sy, mag);
phase(Sx, Sy, ori, true);
orientationMap(ori, 1.0);
return 0;
}
What I want to do know, is to access the Image (ori) and read out the Orientation Values and divid them by 10 to get a number between 0 and 36. And add that one in an array.
The Method I use now just gives me the gray value of the Image.
Here is the Solution for others with the same problem:
int i,j;
int** hist = 0;
hist = new int*[15];
for(i = 0; i < ori.rows; i++){
hist[i] = new int[15];
for(j = 0; j < ori.cols; j++){
float value = round(ori.at(i,j) / 10);
hist[i][j] = value;
}
}
↧
Locate Peaks in Orientation Histogramm
I try to find the Peaks of a Histogramm which was calculated from a Orientation Image which was created through phase(). The Code I use is from this [Anwser](http://answers.opencv.org/question/56701/find-all-peaks-for-mat-in-opencv-c/). Instead of counting every possible Angle I round them and just count every tenth step. (e.g. 11 = 1, 345 = 35 etc.)
My Problem is, that it seems, that the peaks the algorithm found are not right. (Example image at end)
First the Code:
Calculating Histogram and call Peakfinder:
Mat patch = src(Rect(px,py,15,15));
Mat Sx;
Sobel(patch, Sx, CV_32F, 1, 0, 3);
Mat Sy;
Sobel(patch, Sy, CV_32F, 0, 1, 3);
Mat ori;
phase(Sx, Sy, ori, true);
Mat hist;
int nbins = 36;
int hsize[] = {nbins};
float range[] = {0, 360};
const float *ranges[] = {range};
int chnls[] = {0};
bool uniform = true; bool accumulate = false;
calcHist(&ori, 1, chnls, Mat(), hist, 1, hsize, ranges, uniform, accumulate);
vector peaks;
findHistPeaks(hist, peaks);
Here the Peak Finder Methods:
void non_maxima_suppression(const Mat& src, Mat& mask, const bool remove_plateaus){
//find pixels that are equal to the local neighborhood not maximum (including plateaus)
dilate(src, mask, Mat());
compare(src, mask, mask, CMP_GE);
//optionally filter out pixels that are equal to the local minimum ('plateaus')
if(remove_plateaus){
Mat non_plateau_mask;
erode(src, non_plateau_mask, Mat());
compare(src, non_plateau_mask, non_plateau_mask, CMP_GT);
bitwise_and(mask, non_plateau_mask, mask);
}
}
//function that finds the peaks of a given hist image
void findHistPeaks(Mat _src, OutputArray _idx, const float scale= 0.2, const Size& ksize = Size(9,9), const bool remove_plateus = true){
Mat hist = _src.clone();
// find the min and max values of the hist image
double min_val, max_val;
minMaxLoc(hist, &min_val, &max_val);
Mat mask;
GaussianBlur(hist, hist, ksize, 0); //smooth a bit in otder to obtain better result
non_maxima_suppression(hist, mask, remove_plateus);
vector maxima; // Outputs, locations of non-zero pixels
findNonZero(mask, maxima);
for(vector::iterator it = maxima.begin(); it != maxima.end();){
Point pnt = *it;
float pVal = hist.at(/*pnt.x,*/pnt.y -1);
float val = hist.at(/*pnt.x, */ pnt.y);
float nVal = hist.at(/*pnt.x, */pnt.y+1);
// filter peaks
if((val > max_val * scale))
++it;
else
it = maxima.erase(it);
}
Mat(maxima).copyTo(_idx);
}
And drawing the histogram with circles to mark the Peaks:
double maxVal = 0;
minMaxLoc(hist,0,&maxVal,0,0);
int xscale=10;
Mat histImage;
histImage = Mat::zeros(226, 36 * xscale, CV_8UC1);
for(int s = 0; s < 37; s++){
float binVal = hist.at(s,0);
int intensity = cvRound(binVal * 36/maxVal);
rectangle(histImage, Point(s*xscale,histImage.rows), Point((s+1)*xscale-1, histImage.rows - intensity), Scalar(255, 0, 0), 1);
}
for(int i = 0; i < peaks.size(); i++){
circle(histImage, peaks[i], 25, Scalar(255,0,0), 2, LINE_8, 0);
}
imshow("histo", histImage);
When I write the values of peak vector in the console I get this result:
[0, 18]
[0, 21]
[0, 35]
and the Histogram Image looks like this:

↧
OpenCV 3.1 (C++) - SVM.load() does not set var_count correctly
Okay, I have some training data with 35 variables, I trained an SVM classifier and saved it using:
svm->save("trained-svm.xml")
In another application, I was trying to load the classifier using the XML file saved previously, and I encountered an Assertion Failure when I tried to call predict() on a piece of new input data:
OpenCV Error: Assertion failed (samples.cols == var_count && samples.type() == CV_32F) in cv::ml::SVMImpl::predict, file E:\Downloads\opencv\sources\modules\ml\src\svm.cpp, line 1930
I double checked that I have loaded my data as CV_32F type, which means that the assertion failed at samples.cols == var_count. And I double checked that I did have the right number of columns (35) in my test data.
So I tried to print out the var_count as follows:
svm->load("trained-svm.xml");
cout << svm->getVarCount() << endl;
The result is that getVarCount() reports value of -842150451, which is clearly wrong. Since my XML does mention var_count as 35. Apparently load() doesn't update this value, causing the assertion.
3 C_SVC LINEAR 1. 1.1920928955078125e-07 1000
**35 **6 6 1 i
1 2 3 4 5 615
(snipped away rest of XML)
Any solutions to this?
↧
↧
opnecv build fails on rpi3 with Ubuntu 16.04 and ENABLE_NEON=ON
Hello I try to build OpenCv on my Raspberry Pi 3 with Ubuntu 16.04. But when I try to build it with Arm Neon enabled
**My cmake Command is this one:**> cmake -D CMAKE_BUILD_TYPE=RELEASE -D> CMAKE_INSTALL_PREFIX=/usr/local -D> BUILD_WITH_DEBUG_INFO=OFF -D> BUILD_DOCS=OFF -D BUILD_EXAMPLES=OFF> -D BUILD_TESTS=OFF -D BUILD_opencv_ts=OFF -D> BUILD_PERF_TESTS=OFF -D> INSTALL_C_EXAMPLES=ON -D> INSTALL_PYTHON_EXAMPLES=OFF -D> OPENCV_EXTRA_MODULES_PATH=/home/flexpi/opencv_contrib/modules> -DBUILD_opencv_python=OFF -D ENABLE_VFPV3=ON -DENABLE_NEON=ON -D> WITH_LIBV4L=ON -D WITH_TBB=ON ..
**I get this Error.**
> 9%] Building CXX object> 3rdparty/carotene/hal/carotene/CMakeFiles/carotene_objs.dir/src/fast.cpp.o>> [ 9%] Building CXX object> 3rdparty/carotene/hal/carotene/CMakeFiles/carotene_objs.dir/src/channels_combine.cpp.o>> [ 11%] Built target carotene_objs>> Scanning dependencies of target> tegra_hal>> [ 12%] Linking CXX static library> ../../lib/libtegra_hal.a>> [ 12%] Built target tegra_hal>> [ 12%] Building CXX object> modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o>> In file included from> /home/flexpi/opencv/modules/core/include/opencv2/core/cvdef.h:222:0,>> from /home/flexpi/opencv/modules/core/include/opencv2/core.hpp:52,>> from /home/flexpi/opencv/modules/core/include/opencv2/core/utility.hpp:56,>> from /home/flexpi/opencv/modules/core/src/precomp.hpp:49,>> from /home/flexpi/opencv/build/modules/core/opencv_core_pch_dephelp.cxx:1:>> /home/flexpi/opencv/modules/core/include/opencv2/core/hal/intrin_neon.hpp:288:21:> error: expected unqualified-id before>‘__extension__’
>> static inline short> vget_lane_f16(float16x4_t a, int b)>> ^>> /home/flexpi/opencv/modules/core/include/opencv2/core/hal/intrin_neon.hpp:288:21:> error: expected unqualified-id before>‘)’ token
>> static inline short> vget_lane_f16(float16x4_t a, int b)>> ^>> modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/build.make:71:> recipe for target> 'modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o'> failed>> make[2]: ***> [modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o]> Error 1>> CMakeFiles/Makefile2:1912: recipe for> target> 'modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/all'> failed>> make[1]: ***> [modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/all]> Error 2>> Makefile:160: recipe for target 'all'> failed>> make: *** [all] Error 2
**The Cmake Output is:**
> -- The CXX compiler identification is GNU 5.4.0> -- The C compiler identification is GNU 5.4.0> -- Check for working CXX compiler: /usr/bin/g++> -- Check for working CXX compiler: /usr/bin/g++ -- works> -- Detecting CXX compiler ABI info> -- Detecting CXX compiler ABI info - done> -- Detecting CXX compile features> -- Detecting CXX compile features - done> -- Check for working C compiler: /usr/bin/cc> -- Check for working C compiler: /usr/bin/cc -- works> -- Detecting C compiler ABI info> -- Detecting C compiler ABI info - done> -- Detecting C compile features> -- Detecting C compile features - done> -- Detected version of GNU GCC: 54 (504)> -- Performing Test HAVE_CXX_FSIGNED_CHAR> -- Performing Test HAVE_CXX_FSIGNED_CHAR - Success> -- Performing Test HAVE_C_FSIGNED_CHAR> -- Performing Test HAVE_C_FSIGNED_CHAR - Success> -- Performing Test HAVE_CXX_W> -- Performing Test HAVE_CXX_W - Success> -- Performing Test HAVE_C_W> -- Performing Test HAVE_C_W - Success> -- Performing Test HAVE_CXX_WALL> -- Performing Test HAVE_CXX_WALL - Success> -- Performing Test HAVE_C_WALL> -- Performing Test HAVE_C_WALL - Success> -- Performing Test HAVE_CXX_WERROR_RETURN_TYPE> -- Performing Test HAVE_CXX_WERROR_RETURN_TYPE - Success> -- Performing Test HAVE_C_WERROR_RETURN_TYPE> -- Performing Test HAVE_C_WERROR_RETURN_TYPE - Success> -- Performing Test HAVE_CXX_WERROR_NON_VIRTUAL_DTOR> -- Performing Test HAVE_CXX_WERROR_NON_VIRTUAL_DTOR - Success> -- Performing Test HAVE_C_WERROR_NON_VIRTUAL_DTOR> -- Performing Test HAVE_C_WERROR_NON_VIRTUAL_DTOR - Success> -- Performing Test HAVE_CXX_WERROR_ADDRESS> -- Performing Test HAVE_CXX_WERROR_ADDRESS - Success> -- Performing Test HAVE_C_WERROR_ADDRESS> -- Performing Test HAVE_C_WERROR_ADDRESS - Success> -- Performing Test HAVE_CXX_WERROR_SEQUENCE_POINT> -- Performing Test HAVE_CXX_WERROR_SEQUENCE_POINT - Success> -- Performing Test HAVE_C_WERROR_SEQUENCE_POINT> -- Performing Test HAVE_C_WERROR_SEQUENCE_POINT - Success> -- Performing Test HAVE_CXX_WFORMAT> -- Performing Test HAVE_CXX_WFORMAT - Success> -- Performing Test HAVE_C_WFORMAT> -- Performing Test HAVE_C_WFORMAT - Success> -- Performing Test HAVE_CXX_WERROR_FORMAT_SECURITY> -- Performing Test HAVE_CXX_WERROR_FORMAT_SECURITY - Success> -- Performing Test HAVE_C_WERROR_FORMAT_SECURITY> -- Performing Test HAVE_C_WERROR_FORMAT_SECURITY - Success> -- Performing Test HAVE_CXX_WMISSING_DECLARATIONS> -- Performing Test HAVE_CXX_WMISSING_DECLARATIONS - Success> -- Performing Test HAVE_C_WMISSING_DECLARATIONS> -- Performing Test HAVE_C_WMISSING_DECLARATIONS - Success> -- Performing Test HAVE_CXX_WMISSING_PROTOTYPES> -- Performing Test HAVE_CXX_WMISSING_PROTOTYPES - Failed> -- Performing Test HAVE_C_WMISSING_PROTOTYPES> -- Performing Test HAVE_C_WMISSING_PROTOTYPES - Success> -- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES> -- Performing Test HAVE_CXX_WSTRICT_PROTOTYPES - Failed> -- Performing Test HAVE_C_WSTRICT_PROTOTYPES> -- Performing Test HAVE_C_WSTRICT_PROTOTYPES - Success> -- Performing Test HAVE_CXX_WUNDEF> -- Performing Test HAVE_CXX_WUNDEF - Success> -- Performing Test HAVE_C_WUNDEF> -- Performing Test HAVE_C_WUNDEF - Success> -- Performing Test HAVE_CXX_WINIT_SELF> -- Performing Test HAVE_CXX_WINIT_SELF - Success> -- Performing Test HAVE_C_WINIT_SELF> -- Performing Test HAVE_C_WINIT_SELF - Success> -- Performing Test HAVE_CXX_WPOINTER_ARITH> -- Performing Test HAVE_CXX_WPOINTER_ARITH - Success> -- Performing Test HAVE_C_WPOINTER_ARITH> -- Performing Test HAVE_C_WPOINTER_ARITH - Success> -- Performing Test HAVE_CXX_WSHADOW> -- Performing Test HAVE_CXX_WSHADOW - Success> -- Performing Test HAVE_C_WSHADOW> -- Performing Test HAVE_C_WSHADOW - Success> -- Performing Test HAVE_CXX_WSIGN_PROMO> -- Performing Test HAVE_CXX_WSIGN_PROMO - Success> -- Performing Test HAVE_C_WSIGN_PROMO> -- Performing Test HAVE_C_WSIGN_PROMO - Failed> -- Performing Test HAVE_CXX_WNO_NARROWING> -- Performing Test HAVE_CXX_WNO_NARROWING - Success> -- Performing Test HAVE_C_WNO_NARROWING> -- Performing Test HAVE_C_WNO_NARROWING - Success> -- Performing Test HAVE_CXX_WNO_DELETE_NON_VIRTUAL_DTOR> -- Performing Test HAVE_CXX_WNO_DELETE_NON_VIRTUAL_DTOR - Success> -- Performing Test HAVE_C_WNO_DELETE_NON_VIRTUAL_DTOR> -- Performing Test HAVE_C_WNO_DELETE_NON_VIRTUAL_DTOR - Failed> -- Performing Test HAVE_CXX_WNO_UNNAMED_TYPE_TEMPLATE_ARGS> -- Performing Test HAVE_CXX_WNO_UNNAMED_TYPE_TEMPLATE_ARGS - Failed> -- Performing Test HAVE_C_WNO_UNNAMED_TYPE_TEMPLATE_ARGS> -- Performing Test HAVE_C_WNO_UNNAMED_TYPE_TEMPLATE_ARGS - Failed> -- Performing Test HAVE_CXX_WNO_COMMENT> -- Performing Test HAVE_CXX_WNO_COMMENT - Success> -- Performing Test HAVE_C_WNO_COMMENT> -- Performing Test HAVE_C_WNO_COMMENT - Success> -- Performing Test HAVE_CXX_FDIAGNOSTICS_SHOW_OPTION> -- Performing Test HAVE_CXX_FDIAGNOSTICS_SHOW_OPTION - Success> -- Performing Test HAVE_C_FDIAGNOSTICS_SHOW_OPTION> -- Performing Test HAVE_C_FDIAGNOSTICS_SHOW_OPTION - Success> -- Performing Test HAVE_CXX_PTHREAD> -- Performing Test HAVE_CXX_PTHREAD - Success> -- Performing Test HAVE_C_PTHREAD> -- Performing Test HAVE_C_PTHREAD - Success> -- Performing Test HAVE_CXX_FOMIT_FRAME_POINTER> -- Performing Test HAVE_CXX_FOMIT_FRAME_POINTER - Success> -- Performing Test HAVE_C_FOMIT_FRAME_POINTER> -- Performing Test HAVE_C_FOMIT_FRAME_POINTER - Success> -- Performing Test HAVE_CXX_MFP16_FORMAT_IEEE> -- Performing Test HAVE_CXX_MFP16_FORMAT_IEEE - Success> -- Performing Test HAVE_C_MFP16_FORMAT_IEEE> -- Performing Test HAVE_C_MFP16_FORMAT_IEEE - Success> -- Performing Test HAVE_CXX_MFPU_NEON_FP16> -- Performing Test HAVE_CXX_MFPU_NEON_FP16 - Success> -- Performing Test HAVE_C_MFPU_NEON_FP16> -- Performing Test HAVE_C_MFPU_NEON_FP16 - Success> -- Performing Test HAVE_CXX_FFUNCTION_SECTIONS> -- Performing Test HAVE_CXX_FFUNCTION_SECTIONS - Success> -- Performing Test HAVE_C_FFUNCTION_SECTIONS> -- Performing Test HAVE_C_FFUNCTION_SECTIONS - Success> -- Performing Test HAVE_CXX_FVISIBILITY_HIDDEN> -- Performing Test HAVE_CXX_FVISIBILITY_HIDDEN - Success> -- Performing Test HAVE_C_FVISIBILITY_HIDDEN> -- Performing Test HAVE_C_FVISIBILITY_HIDDEN - Success> -- Performing Test HAVE_CXX_FVISIBILITY_INLINES_HIDDEN> -- Performing Test HAVE_CXX_FVISIBILITY_INLINES_HIDDEN - Success> -- Performing Test HAVE_C_FVISIBILITY_INLINES_HIDDEN> -- Performing Test HAVE_C_FVISIBILITY_INLINES_HIDDEN - Failed> -- FP16: Compiler support is available> -- Looking for pthread.h> -- Looking for pthread.h - found> -- Check if the system is big endian> -- Searching 16 bit integer> -- Looking for sys/types.h> -- Looking for sys/types.h - found> -- Looking for stdint.h> -- Looking for stdint.h - found> -- Looking for stddef.h> -- Looking for stddef.h - found> -- Check size of unsigned short> -- Check size of unsigned short - done> -- Using unsigned short> -- Check if the system is big endian - little endian> -- Found ZLIB: /usr/lib/arm-linux-gnueabihf/libz.so (found suitable version "1.2.8", minimum required is "1.2.3") > -- Found TIFF: /usr/lib/arm-linux-gnueabihf/libtiff.so (found version "4.0.6") > -- Found JPEG: /usr/lib/arm-linux-gnueabihf/libjpeg.so > -- Performing Test HAVE_C_WNO_UNUSED_VARIABLE> -- Performing Test HAVE_C_WNO_UNUSED_VARIABLE - Success> -- Performing Test HAVE_C_WNO_UNUSED_FUNCTION> -- Performing Test HAVE_C_WNO_UNUSED_FUNCTION - Success> -- Performing Test HAVE_C_WNO_SHADOW> -- Performing Test HAVE_C_WNO_SHADOW - Success> -- Performing Test HAVE_C_WNO_MAYBE_UNINITIALIZED> -- Performing Test HAVE_C_WNO_MAYBE_UNINITIALIZED - Success> -- Found Jasper: /usr/lib/arm-linux-gnueabihf/libjasper.so (found version "1.900.1") > -- Found ZLIB: /usr/lib/arm-linux-gnueabihf/libz.so (found version "1.2.8") > -- Found PNG: /usr/lib/arm-linux-gnueabihf/libpng.so (found version "1.2.54") > -- Looking for /usr/include/libpng/png.h> -- Looking for /usr/include/libpng/png.h - found> -- Found OpenEXR: /usr/lib/arm-linux-gnueabihf/libIlmImf.so> -- Checking for module 'gtk+-3.0'> -- No package 'gtk+-3.0' found> -- Checking for module 'gtk+-2.0'> -- Found gtk+-2.0, version 2.24.30> -- Checking for module 'gthread-2.0'> -- Found gthread-2.0, version 2.48.1> -- Checking for module 'gstreamer-base-1.0'> -- No package 'gstreamer-base-1.0' found> -- Checking for module 'gstreamer-video-1.0'> -- No package 'gstreamer-video-1.0' found> -- Checking for module 'gstreamer-app-1.0'> -- No package 'gstreamer-app-1.0' found> -- Checking for module 'gstreamer-riff-1.0'> -- No package 'gstreamer-riff-1.0' found> -- Checking for module 'gstreamer-pbutils-1.0'> -- No package 'gstreamer-pbutils-1.0' found> -- Checking for module 'gstreamer-base-0.10'> -- No package 'gstreamer-base-0.10' found> -- Checking for module 'gstreamer-video-0.10'> -- No package 'gstreamer-video-0.10' found> -- Checking for module 'gstreamer-app-0.10'> -- No package 'gstreamer-app-0.10' found> -- Checking for module 'gstreamer-riff-0.10'> -- No package 'gstreamer-riff-0.10' found> -- Checking for module 'gstreamer-pbutils-0.10'> -- No package 'gstreamer-pbutils-0.10' found> -- Checking for module 'libdc1394-2'> -- Found libdc1394-2, version 2.2.4> -- Checking for module 'libv4l1'> -- Found libv4l1, version 1.10.0> -- Checking for module 'libv4l2'> -- Found libv4l2, version 1.10.0> -- Looking for linux/videodev.h> -- Looking for linux/videodev.h - not found> -- Looking for linux/videodev2.h> -- Looking for linux/videodev2.h - found> -- Looking for sys/videoio.h> -- Looking for sys/videoio.h - not found> -- Checking for module 'libavcodec'> -- Found libavcodec, version 56.60.100> -- Checking for module 'libavformat'> -- Found libavformat, version 56.40.101> -- Checking for module 'libavutil'> -- Found libavutil, version 54.31.100> -- Checking for module 'libswscale'> -- Found libswscale, version 3.1.101> -- Checking for module 'libavresample'> -- No package 'libavresample' found> -- Looking for libavformat/avformat.h> -- Looking for libavformat/avformat.h - found> -- Looking for ffmpeg/avformat.h> -- Looking for ffmpeg/avformat.h - not found> -- Checking for module 'libgphoto2'> -- No package 'libgphoto2' found> -- Looking for dgemm_> -- Looking for dgemm_ - found> -- Looking for pthread.h> -- Looking for pthread.h - found> -- Looking for pthread_create> -- Looking for pthread_create - found> -- Found Threads: TRUE > -- A library with BLAS API found.> -- Looking for cheev_> -- Looking for cheev_ - found> -- A library with LAPACK API found.> -- Checking for module 'tbb'> -- Found tbb, version 4.4~20151115> -- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.12", minimum required is "2.7") > -- Found PythonLibs: /usr/lib/arm-linux-gnueabihf/libpython2.7.so (found suitable exact version "2.7.12") > -- Found PythonInterp: /usr/bin/python3 (found suitable version "3.5.2", minimum required is "3.4") > -- Found PythonLibs: /usr/lib/arm-linux-gnueabihf/libpython3.5m.so (found suitable exact version "3.5.2") > -- Could NOT find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) > -- Could NOT find Matlab (missing: MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN) > -- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file> -- Performing Test CXX_HAS_MFPU_NEON> -- Performing Test CXX_HAS_MFPU_NEON - Success> -- Performing Test C_HAS_MFPU_NEON> -- Performing Test C_HAS_MFPU_NEON - Success> -- Performing Test HAVE_CXX_WNO_UNDEF> -- Performing Test HAVE_CXX_WNO_UNDEF - Success> -- Performing Test HAVE_CXX_WNO_SHADOW> -- Performing Test HAVE_CXX_WNO_SHADOW - Success> -- Caffe: NO> -- Protobuf: NO> -- Glog: NO> -- Could NOT find HDF5 (missing: HDF5_LIBRARIES HDF5_INCLUDE_DIRS) > -- Checking SFM deps... FALSE> -- Module opencv_sfm disabled because the following dependencies are not found: Glog/Gflags> -- Performing Test HAVE_CXX_WNO_PARENTHESES> -- Performing Test HAVE_CXX_WNO_PARENTHESES - Success> -- Performing Test HAVE_CXX_WNO_MAYBE_UNINITIALIZED> -- Performing Test HAVE_CXX_WNO_MAYBE_UNINITIALIZED - Success> -- Performing Test HAVE_CXX_WNO_SIGN_PROMO> -- Performing Test HAVE_CXX_WNO_SIGN_PROMO - Success> -- Performing Test HAVE_CXX_WNO_MISSING_DECLARATIONS> -- Performing Test HAVE_CXX_WNO_MISSING_DECLARATIONS - Success> -- Performing Test HAVE_CXX_WNO_MISSING_PROTOTYPES> -- Performing Test HAVE_CXX_WNO_MISSING_PROTOTYPES - Failed> -- Could NOT find Protobuf (missing: PROTOBUF_LIBRARY PROTOBUF_INCLUDE_DIR) > -- Build libprotobuf from sources:> -- libprotobuf not found into system> -- The protocol buffer compiler not found> -- Looking for include file pthread.h> -- Looking for include file pthread.h - found> -- Looking for C++ include unordered_map> -- Looking for C++ include unordered_map - found> -- Looking for C++ include tr1/unordered_map> -- Looking for C++ include tr1/unordered_map - found> -- Looking for C++ include unordered_set> -- Looking for C++ include unordered_set - found> -- Looking for C++ include tr1/unordered_set> -- Looking for C++ include tr1/unordered_set - found> -- Performing Test HAVE_CXX_WNO_DEPRECATED> -- Performing Test HAVE_CXX_WNO_DEPRECATED - Success> -- Performing Test HAVE_CXX_WNO_UNUSED_PARAMETER> -- Performing Test HAVE_CXX_WNO_UNUSED_PARAMETER - Success> -- Performing Test HAVE_CXX_WNO_UNUSED_LOCAL_TYPEDEFS> -- Performing Test HAVE_CXX_WNO_UNUSED_LOCAL_TYPEDEFS - Success> -- Performing Test HAVE_CXX_WNO_SIGN_COMPARE> -- Performing Test HAVE_CXX_WNO_SIGN_COMPARE - Success> -- Performing Test HAVE_CXX_WNO_TAUTOLOGICAL_UNDEFINED_COMPARE> -- Performing Test HAVE_CXX_WNO_TAUTOLOGICAL_UNDEFINED_COMPARE - Failed> -- Performing Test HAVE_CXX_WNO_DEPRECATED_DECLARATIONS> -- Performing Test HAVE_CXX_WNO_DEPRECATED_DECLARATIONS - Success> -- Tesseract: NO> -- > -- General configuration for OpenCV 3.1.0-dev =====================================> -- Version control: 3.1.0-1374-g7f14a27-dirty> -- > -- Extra modules:> -- Location (extra): /home/flexpi/opencv_contrib/modules> -- Version control (extra): 3.1.0-356-gaa5281c-dirty> -- > -- Platform:> -- Timestamp: 2016-09-27T04:49:01Z> -- Host: Linux 4.4.21-v7+ armv7l> -- CMake: 3.5.1> -- CMake generator: Unix Makefiles> -- CMake build tool: /usr/bin/make> -- Configuration: RELEASE> -- > -- C/C++:> -- Built as dynamic libs?: YES> -- C++ Compiler: /usr/bin/g++ (ver 5.4.0)> -- C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfp16-format=ieee -mfpu=neon-fp16 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG> -- C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfp16-format=ieee -mfpu=neon-fp16 -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG> -- C Compiler: /usr/bin/cc> -- C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfp16-format=ieee -mfpu=neon-fp16 -ffunction-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG> -- C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfp16-format=ieee -mfpu=neon-fp16 -ffunction-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG> -- Linker flags (Release):> -- Linker flags (Debug):> -- Precompiled headers: YES> -- Extra dependencies: /usr/lib/arm-linux-gnueabihf/libpng.so /usr/lib/arm-linux-gnueabihf/libz.so /usr/lib/arm-linux-gnueabihf/libtiff.so /usr/lib/arm-linux-gnueabihf/libjasper.so /usr/lib/arm-linux-gnueabihf/libjpeg.so /usr/lib/arm-linux-gnueabihf/libImath.so /usr/lib/arm-linux-gnueabihf/libIlmImf.so /usr/lib/arm-linux-gnueabihf/libIex.so /usr/lib/arm-linux-gnueabihf/libHalf.so /usr/lib/arm-linux-gnueabihf/libIlmThread.so gtk-x11-2.0 gdk-x11-2.0 pangocairo-1.0 atk-1.0 cairo gdk_pixbuf-2.0 gio-2.0 pangoft2-1.0 pango-1.0 gobject-2.0 fontconfig freetype gthread-2.0 glib-2.0 dc1394 v4l1 v4l2 avcodec-ffmpeg avformat-ffmpeg avutil-ffmpeg swscale-ffmpeg /lib/arm-linux-gnueabihf/libbz2.so.1 dl m pthread rt tbb atomic> -- 3rdparty dependencies: libwebp libprotobuf tegra_hal> -- > -- OpenCV modules:> -- To be built: core flann imgproc ml photo reg surface_matching video dnn fuzzy imgcodecs shape videoio highgui objdetect plot superres xobjdetect xphoto bgsegm bioinspired dpm face features2d line_descriptor saliency text calib3d ccalib datasets rgbd stereo structured_light tracking videostab xfeatures2d ximgproc aruco optflow stitching python2 python3> -- Disabled: world contrib_world> -- Disabled by dependency: -> -- Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java ts viz cvv hdf matlab sfm> -- > -- GUI: > -- QT: NO> -- GTK+ 2.x: YES (ver 2.24.30)> -- GThread : YES (ver 2.48.1)> -- GtkGlExt: NO> -- OpenGL support: NO> -- VTK support: NO> -- > -- Media I/O: > -- ZLib: /usr/lib/arm-linux-gnueabihf/libz.so (ver 1.2.8)> -- JPEG: /usr/lib/arm-linux-gnueabihf/libjpeg.so (ver )> -- WEBP: build (ver 0.3.1)> -- PNG: /usr/lib/arm-linux-gnueabihf/libpng.so (ver 1.2.54)> -- TIFF: /usr/lib/arm-linux-gnueabihf/libtiff.so (ver 42 - 4.0.6)> -- JPEG 2000: /usr/lib/arm-linux-gnueabihf/libjasper.so (ver 1.900.1)> -- OpenEXR: /usr/lib/arm-linux-gnueabihf/libImath.so /usr/lib/arm-linux-gnueabihf/libIlmImf.so /usr/lib/arm-linux-gnueabihf/libIex.so /usr/lib/arm-linux-gnueabihf/libHalf.so /usr/lib/arm-linux-gnueabihf/libIlmThread.so (ver 2.2.0)> -- GDAL: NO> -- GDCM: NO> -- > -- Video I/O:> -- DC1394 1.x: NO> -- DC1394 2.x: YES (ver 2.2.4)> -- FFMPEG: YES> -- codec: YES (ver 56.60.100)> -- format: YES (ver 56.40.101)> -- util: YES (ver 54.31.100)> -- swscale: YES (ver 3.1.101)> -- resample: NO> -- gentoo-style: YES> -- GStreamer: NO> -- OpenNI: NO> -- OpenNI PrimeSensor Modules: NO> -- OpenNI2: NO> -- PvAPI: NO> -- GigEVisionSDK: NO> -- UniCap: NO> -- UniCap ucil: NO> -- V4L/V4L2: Using libv4l1 (ver 1.10.0) / libv4l2 (ver 1.10.0)> -- XIMEA: NO> -- Xine: NO> -- gPhoto2: NO> -- > -- Parallel framework: TBB (ver 4.4 interface 9002)> -- > -- Other third-party libraries:> -- Use IPP: NO> -- Use VA: NO> -- Use Intel VA-API/OpenCL: NO> -- Use Lapack: NO> -- Use Eigen: YES (ver 3.2.92)> -- Use Cuda: NO> -- Use OpenCL: YES> -- Use OpenVX: NO> -- Use custom HAL: YES (carotene (ver 0.0.1))> -- > -- OpenCL: > -- Include path: /home/flexpi/opencv/3rdparty/include/opencl/1.2> -- Use AMDFFT: NO> -- Use AMDBLAS: NO> -- > -- Python 2:> -- Interpreter: /usr/bin/python2.7 (ver 2.7.12)> -- Libraries: /usr/lib/arm-linux-gnueabihf/libpython2.7.so (ver 2.7.12)> -- numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.11.0)> -- packages path: lib/python2.7/dist-packages> -- > -- Python 3:> -- Interpreter: /usr/bin/python3 (ver 3.5.2)> -- Libraries: /usr/lib/arm-linux-gnueabihf/libpython3.5m.so (ver 3.5.2)> -- numpy: /usr/lib/python3/dist-packages/numpy/core/include (ver 1.11.0)> -- packages path: lib/python3.5/dist-packages> -- > -- Python (for build): /usr/bin/python2.7> -- > -- Java:> -- ant: NO> -- JNI: NO> -- Java wrappers: NO> -- Java tests: NO> -- > -- Matlab: Matlab not found or implicitly disabled> -- > -- Tests and samples:> -- Tests: NO> -- Performance tests: NO> -- C/C++ Examples: NO> -- > -- Install path: /usr/local> -- > -- cvconfig.h is in: /home/flexpi/opencv/build> -- -----------------------------------------------------------------> -- > -- Configuring done> -- Generating done> -- Build files have been written to: /home/flexpi/opencv/build
↧
How to convert SFML image to OpenCV Mat in c++?
Below code is used to convert an OpenCV Mat image into SFML image. How to convert SFML image back to Mat image?
cv::Mat frameBGR, frameBGRA;
sf::Image image;
cv::cvtColor(frameBGR,frameRGBA,
cv::COLOR_BGR2RGBA);
image.create(frameRGBA.cols,
frameRGBA.rows, frameRGBA.ptr());
If texture or sprite can't be converted to OpenCV Mat,then is it possible to convert sf::Image to OpenGL and convert it back to cv::Mat
sf::Texture texture;
sf::Event event;
sf::Sprite sprite;
texture.loadFromImage(image);
sprite.setTexture(texture);
**Update:** I referred [this][1] post, but still was not able to convert.
void* buffer = ℑ
cv::Mat image_mat = cv::Mat(cvSize(500, 500),CV_8UC4, buffer, cv::Mat::AUTO_STEP);
cvtColor(image_mat, converted,CV_RGBA2BGR);
It crashes at below line of code (when i display image )
imshow("img", converted);
[1]: http://stackoverflow.com/questions/31854738/how-to-create-an-image-in-opencv-from-a-buffer-that-holds-image-in-rgba-format
↧
Mat::clone() issues
Hello,
I am using a method for thinning an image. The method is beeing executed by a single thread.
void applyThreadedThinning(Mat* input) {
Mat output = input->clone();
.....
}
I use MSVC 2015 (32bit) and the plugin Image Watch, which lets me see the content of the image while debugging.
After I set a breakpoint do the line with the clone()... i noticed, that the input image looks fine, but the cloned one is a plain image, filled with values 217 (8bit greyscale).
After jumping to the next line in the debugger, both images are "invalid".
Strange thing is, if I execute the method directly in the main method (not using a thread), it works fine. The threaded(std::thread t1(...)) version aborts during runtime.
Why is the clone method not working as intended? Is it something with scopes?
Thanks
↧