Angle correction of each line in an article
I want to correct each line in an article. if you have any idea please help me. i have used hough transformation to detect lines. but it doesn't work for all articles. so if you have any idea please help me...
#include "stdafx.h"
#include<opencv\cv.h>
#include<opencv\cxcore.h>
#include<opencv\highgui.h>
#include <math.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
IplImage* src = cvLoadImage("110.jpg");
IplImage* dst;
IplImage* color_dst;
IplImage* tempx = cvCreateImage(cvGetSize(src),IPL_DEPTH_16S,1);
CvMemStorage* storage = cvCreateMemStorage(0);
CvSeq* lines = 0;
int i;
if( !src )
return -1;
dst = cvCreateImage( cvGetSize(src), 8, 1 );
color_dst = cvCreateImage( cvGetSize(src), 8, 3 );
cvCanny( src, dst, 50, 200, 3 );
cvCvtColor( dst, color_dst, CV_GRAY2BGR );
CvSize size = cvGetSize(dst);
lines = cvHoughLines2( dst, storage, CV_HOUGH_PROBABILISTIC, 1, CV_PI/45, 50, 50, 10 );
for( i = 0; i < lines->total; i++ )
{
CvPoint* line = (CvPoint*)cvGetSeqElem(lines,i);
cvLine( color_dst, line[0], line[1], /*CV_RGB(255,0,0)*/cvScalar(255, 0 ,0), 4, CV_AA, 0 );
}
cvNamedWindow( "Source", 1 );
cvShowImage( "Source", dst );
cvNamedWindow( "Hough", 1 );
cvShowImage( "Hough", color_dst );
cvWaitKey(0);
return 0;
}
Please read FAQ. This forum is meant to help people with their implementation problems, not for supplying complete solutions to problems. Provide us some of the code and output you already have, improve the question, show us when it goes wrong, and then people will be more eagered to help. If you don't update your topic, it will get closed.