I want to draw a sine wave on an image using openCV. I developed the following code, but the result does not fit as expected:
#include "opencv2/imgproc/imgproc.hpp" #include "opencv2/highgui/highgui.hpp" #include <stdlib.h> #include <stdio.h> #include <math.h> #include "opencv/cv.h" #include "opencv/highgui.h" void main() { double y[100]; float x; for(x=0;x<100;x++) { y[(int)floor(x)]=sin(x); } IplImage *grf = cvCreateImage( cvSize( 200, 200), IPL_DEPTH_8U, 1 ); for(int x=0;x<100;x++) { cvLine(grf , /* the dest image */ cvPoint(x, y[x]), /* start point */ cvPoint(x+1, y[x+1]), /* end point */ CV_RGB(255, 0, 0), /* the color; green */ 2, 4, 0); /* thickness, line type, shift */ } cvNamedWindow("img", CV_WINDOW_AUTOSIZE); cvShowImage("img", grf); cvWaitKey(0); cvDestroyWindow("img"); cvReleaseImage(&grf); }
I checked that the values ββcoming into the y array are correct, and plotted these y values ββusing MATLAB. The MATLAB graph fits a sine wave. Can you tell me why I am not getting the correct plot using the code above.
My output sine wave graph goes like this: you can see that I am just getting a horizontal line instead of a sine wave. Any help on this?

SOLVED: after the answer, I got the following image:
thanks
geeta source share