2020-12-23 09:46:52 -0600
| received badge | ● Popular Question
(source)
|
2020-12-05 13:45:58 -0600
| received badge | ● Popular Question
(source)
|
2019-10-12 11:02:31 -0600
| received badge | ● Notable Question
(source)
|
2018-11-09 09:13:42 -0600
| received badge | ● Popular Question
(source)
|
2015-12-26 07:45:41 -0600
| asked a question | How to calculate Similarity Rate of 2 feature matching. Hi, I am matching 2 images by their features in openCV ( I've used SURF specially but I am going to compare all other methods too. Depending on match rate) I want to get similarity rate of 2 images e.g A image %85 similar to B image.
how can I do it? P.S: I am looking for good opencv svm tutorial since it is lack of documentation. |
2015-03-25 08:10:01 -0600
| commented answer | How can I rotate images depends on a specific angle ? I just don't want to be part of weird conversation. actually tried delete post but system does not allowed me. |
2015-03-24 10:07:19 -0600
| commented answer | How can I rotate images depends on a specific angle ? I am not complaining I was kindly told all images can come in different angles those methods can detect angle and rotated based on this angles. but his answer was like I did not read documentation thousand times. |
2015-03-19 07:06:04 -0600
| commented answer | How can I rotate images depends on a specific angle ? all images comes in different angles are these methods detect angle and then rotates ? |
2015-03-19 06:08:44 -0600
| asked a question | How can I rotate images depends on a specific angle ? Hi, I need to rotate all images to spesific angle to do OCR. I have to do it because after polar2cartesian transformation sometimes my characters get cropped. here example of my images. |
2015-03-14 06:13:14 -0600
| received badge | ● Scholar
(source)
|
2015-03-14 06:13:10 -0600
| received badge | ● Supporter
(source)
|
2015-03-13 09:50:22 -0600
| asked a question | How to extract contours bigger than some size? Hi, I am trying to extract characters from the image. this is my original image. after some preprocessing I found contours like that; how can I extract those contours from this image ? |
2015-03-07 01:11:14 -0600
| asked a question | How can I recognize characters on the Image Hi, I am trying to do optical character recognition on some images. this is my real image. and after some preprocessing I've recieved this. First of all is this image good enough to OCR ? if so what are the suggested methods that I can use thank you. |
2015-02-26 10:03:05 -0600
| received badge | ● Student
(source)
|
2015-02-21 05:09:20 -0600
| received badge | ● Editor
(source)
|
2015-02-21 04:57:20 -0600
| asked a question | How to Rotate Image based on a template/feature Hello, I'd like to rotate my circular image based a detected feature or template image. so my images will be exactly the same rotated. lets say this is my original image when I give this image as input. it should detect small circle's template or feature then rotate it while those two images will be same. |
2015-02-01 00:28:48 -0600
| asked a question | Wrong Recognition on OpenCV Hello I am trying to match features on opencv using SURF and FLANN. when the object exists my results are fine. however when I paint out the object it still matches. what can actually be the problem I am not sure. #include <stdio.h>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
Mat charZ = imread( "/match/1.jpg",CV_LOAD_IMAGE_GRAYSCALE );
Mat img_scene = imread("ccp.jpg", CV_LOAD_IMAGE_GRAYSCALE );
if( !charZ.data || !img_scene.data )
{ std::cout<< " --(!) Error reading images " << std::endl; return -1; }
//-- Step 1: Detect the keypoints using SURF Detector
int minHessian = 400;
SurfFeatureDetector detector( minHessian );
std::vector<KeyPoint> keypoints_object, keypoints_scene;
detector.detect( charZ, keypoints_object );
detector.detect( img_scene, keypoints_scene );
//-- Step 2: Calculate descriptors (feature vectors)
SurfDescriptorExtractor extractor;
Mat descriptors_object, descriptors_scene;
extractor.compute( charZ, keypoints_object, descriptors_object );
extractor.compute( img_scene, keypoints_scene, descriptors_scene );
//-- Step 3: Matching descriptor vectors using FLANN matcher
FlannBasedMatcher matcher;
std::vector< DMatch > matches;
matcher.match( descriptors_object, descriptors_scene, matches );
double min_dist = 100; double max_dist = 0;
//-- Quick calculation of max and min distances between keypoints
for( int i = 0; i < descriptors_object.rows; i++ )
{ double dist = matches[i].distance;
if( dist < min_dist ) min_dist = dist;
if( dist > max_dist ) max_dist = dist;
}
printf("-- Max dist : %f \n", max_dist );
printf("-- Min dist : %f \n", min_dist );
//-- Draw only "good" matches (i.e. whose distance is less than 3*min_dist )
std::vector< DMatch > good_matches;
for( int i = 0; i < descriptors_object.rows; i++ )
{ if( matches[i].distance < 3*min_dist )
{ good_matches.push_back( matches[i]); }
}
Mat img_matches;
drawMatches( charZ, keypoints_object, img_scene, keypoints_scene,
good_matches, img_matches, Scalar::all(-1), Scalar::all(-1),
vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
//-- Localize the object
std::vector<Point2f> obj;
std::vector<Point2f> scene;
for( int i = 0; i < good_matches.size(); i++ )
{
//-- Get the keypoints from the good matches
obj.push_back( keypoints_object[ good_matches[i].queryIdx ].pt );
scene.push_back( keypoints_scene[ good_matches[i].trainIdx ].pt );
}
//-- Show detected matches
resize(img_matches, img_matches, Size(img_matches.cols/2, img_matches.rows/2));
namedWindow( "match", WINDOW_AUTOSIZE );
imshow( "match", img_matches );
waitKey(0);
return 0;
}
Here are the images I've used. thanks in advance. |
2015-01-13 02:46:58 -0600
| received badge | ● Enthusiast
|
2015-01-12 13:40:49 -0600
| asked a question | Good example of using fast algorithm with opencv and c++ hey I found python codes can someone give me example for c++ ? |
2015-01-08 03:35:55 -0600
| asked a question | Extract each label after Connected Component Labeling Hello after doing a connected component labeling how can I extract each label in a different image file ? here is my code
and this is my image
#include <iostream>
#include <vector>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
void FindBlobs(const cv::Mat &binary, std::vector < std::vector<cv::Point2i> > &blobs);
int main(int argc, char **argv)
{
cv::Mat img = cv::imread("/Users/Rodrane/Documents/XCODE/test/makalesvm/cumartesi.png", 0); if(!img.data) {
std::cout << "File not found" << std::endl;
return -1;
}
cv::namedWindow("binary");
cv::namedWindow("labelled");
cv::Mat output = cv::Mat::zeros(img.size(), CV_8UC3);
cv::Mat binary;
std::vector < std::vector<cv::Point2i > > blobs;
cv::threshold(img, binary, 0.0, 1.0, cv::THRESH_BINARY_INV);
FindBlobs(binary, blobs);
// Randomy color the blobs
for(size_t i=0; i < blobs.size(); i++) {
unsigned char r = 255 * (rand()/(1.0 + RAND_MAX));
unsigned char g = 255 * (rand()/(1.0 + RAND_MAX));
unsigned char b = 255 * (rand()/(1.0 + RAND_MAX));
for(size_t j=0; j < blobs[i].size(); j++) {
int x = blobs[i][j].x;
int y = blobs[i][j].y;
output.at<cv::Vec3b>(y,x)[0] = b;
output.at<cv::Vec3b>(y,x)[1] = g;
output.at<cv::Vec3b>(y,x)[2] = r;
}
}
cv::imshow("binary", img);
cv::imshow("labelled", output);
cv::waitKey(0);
return 0;
}
void FindBlobs(const cv::Mat &binary, std::vector < std::vector<cv::Point2i> > &blobs)
{
blobs.clear();
// Fill the label_image with the blobs
// 0 - background
// 1 - unlabelled foreground
// 2+ - labelled foreground
cv::Mat label_image;
binary.convertTo(label_image, CV_32SC1);
int label_count = 2; // starts at 2 because 0,1 are used already
for(int y=0; y < label_image.rows; y++) {
int *row = (int*)label_image.ptr(y);
for(int x=0; x < label_image.cols; x++) {
if(row[x] != 1) {
continue;
}
cv::Rect rect;
cv::floodFill(label_image, cv::Point(x,y), label_count, &rect, 0, 0, 4);
std::vector <cv::Point2i> blob;
for(int i=rect.y; i < (rect.y+rect.height); i++) {
int *row2 = (int*)label_image.ptr(i);
for(int j=rect.x; j < (rect.x+rect.width); j++) {
if(row2[j] != label_count) {
continue;
}
blob.push_back(cv::Point2i(j,i));
}
}
blobs.push_back(blob);
label_count++;
}
}
}
|
2015-01-01 05:41:27 -0600
| asked a question | Using SURF Feature Algorithm on OpenCV 3.0 hello I am trying to use SURF on opencv 3.0 but it gives me a error "SurfFeatureDetector" undeclerad identifier. here is my code. thanks in advance #include <stdio.h>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/features2d/features2d.hpp"
using namespace cv;
void readme();
/**
* @function main
* @brief Main function
*/
int main( int argc, char** argv )
{
Mat img_1 = imread("C:/opencv/photos/1.jpg", 0 );
Mat img_2 = imread("C:/opencv/photos/template.jpg", 0 );
if( !img_1.data || !img_2.data )
{ std::cout<< " --(!) Error reading images " << std::endl; return -1; }
//-- Step 1: Detect the keypoints using SURF Detector
int minHessian = 400;
SurfFeatureDetector detector( minHessian );
std::vector<KeyPoint> keypoints_1, keypoints_2;
detector.detect( img_1, keypoints_1 );
detector.detect( img_2, keypoints_2 );
//-- Step 2: Calculate descriptors (feature vectors)
SurfDescriptorExtractor extractor;
Mat descriptors_1, descriptors_2;
extractor.compute( img_1, keypoints_1, descriptors_1 );
extractor.compute( img_2, keypoints_2, descriptors_2 );
//-- Step 3: Matching descriptor vectors using FLANN matcher
FlannBasedMatcher matcher;
std::vector< DMatch > matches;
matcher.match( descriptors_1, descriptors_2, matches );
double max_dist = 0; double min_dist = 100;
//-- Quick calculation of max and min distances between keypoints
for( int i = 0; i < descriptors_1.rows; i++ )
{ double dist = matches[i].distance;
if( dist < min_dist ) min_dist = dist;
if( dist > max_dist ) max_dist = dist;
}
printf("-- Max dist : %f \n", max_dist );
printf("-- Min dist : %f \n", min_dist );
//-- Draw only "good" matches (i.e. whose distance is less than 2*min_dist,
//-- or a small arbitary value ( 0.02 ) in the event that min_dist is very
//-- small)
//-- PS.- radiusMatch can also be used here.
std::vector< DMatch > good_matches;
for( int i = 0; i < descriptors_1.rows; i++ )
{ if( matches[i].distance <= max(2*min_dist, 0.02) )
{ good_matches.push_back( matches[i]); }
}
//-- Draw only "good" matches
Mat img_matches;
drawMatches( img_1, keypoints_1, img_2, keypoints_2,
good_matches, img_matches, Scalar::all(-1), Scalar::all(-1),
vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
//-- Show detected matches
imshow( "Good Matches", img_matches );
for( int i = 0; i < (int)good_matches.size(); i++ )
{ printf( "-- Good Match [%d] Keypoint 1: %d -- Keypoint 2: %d \n", i, good_matches[i].queryIdx, good_matches[i].trainIdx ); }
waitKey(0);
return 0;
}
/**
* @function readme
*/
void readme()
{ std::cout << " Usage: ./SURF_FlannMatcher <img1> <img2>" << std::endl; }
|
2014-12-30 08:46:46 -0600
| asked a question | Use of CartToPolar and PolarToCart functions hey, I am looking usage of this functions to obtain a cartesian image but to be honest I didnt really understand the documentation of this functions. so does anyone can help me out how to use those functions ?
The image I'd like to process is below. thanks in advance |