I have a C + + OpenCV code that I need to convert to C. But I could not find a guide to check what I want instead, if you see any other problem in your code, can you tell me?
cvScalar, cvNamedWindow, cvSmooth
Use instead>
#include "cv.h" #include "highgui. H "#include" cxcore.h "#include & lt; Stdio.h & gt; IplImage * range (IplImage * src) {IplImage * srcHSV = cvCreateImage (cvGetSize (source), 8, 3); CvCvtColor (src, srcHSV, CV_BGR2HSV); // BGR Convert HSV IplImage * Thresholdimg = cvCreateImage (cvGetSize (SRC), 8, 1); // Create a Threshold Image // HSV Traceholding CVInlines (srcHSV, CVSLAR (7, 107, 219), CVSLAR (11,148,255), Thresholdming); CvSmooth (Thresholdmig, Thraßhold, CV_ GAUSSIAN, 9, 9); // Smoothing CVRillage image (& amp; srcHSV) with a Gaussian filter (9 * 9 kernels); Return threshold } Int main () {CvCapture * capture = 0; Capture for USB Webcam = CVCCPEUFRUMCAM (1); // 1, 0 o / w If (! Capture) {printf ("can not be captured, no device was found \ n"); Return -1; } // Windows CVNIDW for "Threshold and Output" ("Tracking Output"); CvNamedWindow ("threshold"); While (1) // infinite loop (IplImage * frame = 0; Frame = cvQueryFrame (capture); // Do Dikanpres the frames captured if (! Frame) break; IplImage * finalthreshold = Threshold (frame); cvShowImage ( " threshold ", finalthreshold); // thresholded image show CvMemStorage * storage = cvCreateMemStorage (0); // to contour information CvSeq store allocate memory * circles = cvHoughCircles (finalthreshold, storage, CV_HOUGH_GRADIENT, 2, finalthreshold- & gt height (Float * p = (float *) cvGetSeqElem (circle, / 4, 100, 40, 20, 200); Int i; (I = 0; i & lt; circle-> total; i ++) I); Printf ("Ball! X =% fy =% Fr =% f \ n \ r ", p [0], p [1], p [2]); cvpoint center = cvpint (CRRand (p [0]), CRRand (p [1]); CVScalar val = cvGet2D (Fndlstrold, center, top, center. X); if (val Kvl [0] & lt; 1) continue; Sivisikrikl (frame, center, 3, Sivi_arjibi (0, 255,0), - 1, Sivi_aa, 0); CvCircle (Frame, center, Cr rounds (P [2]), Sivi_arjibi (255,0,0), 3, Sivi_aa, 0); CvCircle (Fndlstrold, center, 3, Sivi_arjibi (0, 255,0), -1, CV_AA, 0); CvCircle (FundralstrollHold, Center, CR Round (P [2]), CV_RGB (255,0,0), 3, CV_AA, 0); } CvShowImage ("Tracking Output", Frame); Int c = cvWaitKey (27); If break (C! = - 1); CvReleaseImage (& amp; finalthreshold); } CvReleaseCapture (and Capture); Return 0; } Here are the errors:
root @ ghostrider: / home / zero / desktop / deneme opencv # opencv untitled.c unchecked. .c: "threshold" in function ????: untitled.c: 17: 2: error: very few arguments to work in "cvScalarâ" file / usr / local / include / opencv2 / core / core_c .h_detail, from /usr/local/include/opencv/cv.h:63, without title: c: 1: / usr / local /include/opencv2/core/types_c.h:1224:22: note : Title declared here.: 17: 2: Error: Too few arguments to work are included in the "cvScalarâ ????" file /usr/local/include/opencv2/core/core_c.h_detail, / Usr / local / include / opencv / cv.h: 63, untitled. C: 1: / usr / local to /include/opencv2/core/types_c.h:1224:22: Note: here it has been declared. C: 19: 2: Error: Too few arguments to work include "cvSmooth" in the file /usr/local/include/opencv/cv.h:65x from untitled.c from: 1: / usr / local / include / opencv2 /imgproc/imgproc_c.h:81:13: Note: Announced unchecked here: C: Function "A" main: ????: untitled.c: 42: 2: Error: Too few arguments to work "cvNamedWindowâ? ??? File included /usr/local/include/opencv/highgui.h:47:0 in untitled.c: 2: /usr/local/include/opencv2/highgui/highgui_c.h:120:12: Note: Declared Uncharted here. C: 43: 2: Error: Too few arguments to work include in the "cvnmd window" file /usr/local/include/opencv/highgui.h:47cript from untitled.c to: 2: / Usr / local / include / opencv2 / highgui / highgui_c.h: 120: 12: note: declares output file = & gt; Anonymous line 1224 /usr/local/include/opencv2/core/types_c.h
CV_INLINE CvScalar cvScalar ( Double val 0, double val 1 cv_default (0), double val 2 cv_default (0), double val 3 cv_default (0))
The constructions you mention are present in C under their name. You can continue to use them using C API instead of C ++ API.
Edit: Note that the implementation of C is not the default argument you will need to provide all the arguments on each function, even if Only you are sticking to the default ones See for more information.