I'm working on a music recognition Android app, which should recognize music annotations in sheet in real time using camera.
When I try to recognize lines or circles using Hough transform (either HoughCircles or HoughLinesP), I get the Unspecified error:
E/cv::error(): OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvWaitKey, file /hdd2/buildbot/slaves/slave_ardbeg1/50-SDK/opencv/modules/highgui/src/window.cpp, line 567
A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 7772 (Thread-411)
I could try another version of OpenCV, but I don't have enough time to change everything. I'm also not skilled with OpenCV, this is the first time I'm using it. Maybe the problem is in c++ file or header.
C++ file:
#include "com_ryu_musicreader_OpencvClass.h"
JNIEXPORT void JNICALL Java_com_ryu_musicreader_OpencvClass_musicDetection
(JNIEnv *, jclass, jlong addrRgba){
Mat& frame = *(Mat*)addrRgba;
find_lines(frame);
find_circles(frame);
}
void find_lines(Mat& src){
Mat dst, cdst;
Canny(src, dst, 50, 200, 3);
cvtColor(dst, cdst, COLOR_GRAY2BGR);
vector<Vec4i> lines;
HoughLinesP(dst, lines, 1, CV_PI/180, 50, 50, 10 );
for( size_t i = 0; i < lines.size(); i++ )
{
Vec4i l = lines[i];
line( cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, 0);
}
imshow("detected lines", cdst);
}
int find_circles(Mat& src){
Mat src_gray;
cvtColor(src, src_gray, COLOR_BGR2GRAY);
GaussianBlur( src_gray, src_gray, Size(9, 9), 2, 2 );
vector<Vec3f> circles;
HoughCircles( src_gray, circles, CV_HOUGH_GRADIENT, 1, src_gray.rows/8, 200, 100, 0, 0 );
for( size_t i = 0; i < circles.size(); i++ )
{
Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
int radius = cvRound(circles[i][2]);
circle( src, center, 3, Scalar(0,255,0), -1, 8, 0 );
circle( src, center, radius, Scalar(0,0,255), 3, 8, 0 );
}
namedWindow( "Hough Circle Transform Demo", CV_WINDOW_AUTOSIZE );
imshow( "Hough Circle Transform Demo", src );
waitKey(0);
return 0;
}
Header file:
#include <jni.h>
#include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
using namespace cv;
#ifndef _Included_com_ryu_musicreader_OpencvClass
#define _Included_com_ryu_musicreader_OpencvClass
#ifdef __cplusplus
extern "C" {
#endif
void detect(Mat& frame);
void find_lines(Mat& frame);
int find_circles(Mat& frame);
JNIEXPORT void JNICALL Java_com_ryu_musicreader_OpencvClass_musicDetection
(JNIEnv *, jclass, jlong);
#ifdef __cplusplus
}
#endif
#endif
It's highly possible that there's something wrong with the code, since I'm not entirely sure how the Hough transform works, so I tried to use some implementations that I found online.
I'd really appreciated any help.