Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用cvPutText()_C_Opencv_Raspberry Pi - Fatal编程技术网

使用cvPutText()

使用cvPutText(),c,opencv,raspberry-pi,C,Opencv,Raspberry Pi,我正试图在屏幕上打印文本,但不断出现错误 有人能帮我写代码吗 cvNamedWindow("Result", CV_NORMAL); cvMoveWindow("Result", 350,300); cvRectangle(img, cvPoint(0,0), cvPoint(2600,2000),cvScalarAll(255), CV_FILLED,8,0); cvShowImage("Result", img); cvPutText(img, mytext,cvPoint(100,100)

我正试图在屏幕上打印文本,但不断出现错误

有人能帮我写代码吗

cvNamedWindow("Result", CV_NORMAL);
cvMoveWindow("Result", 350,300);
cvRectangle(img, cvPoint(0,0), cvPoint(2600,2000),cvScalarAll(255), CV_FILLED,8,0);
cvShowImage("Result", img);
cvPutText(img, mytext,cvPoint(100,100),CV_FONT_HERSHEY_SIMPLEX,cvScalarAll(0));
cvWaitKey(0);
我得到的错误是

OpenCV Error: Assertion failed (text != 0 && _font != 0) in cvPutText, file /build/opencv-XZa2gn/opencv-2.3.1/modules/core/src/drawing.cpp, line 2375
terminate called after throwing an instance of 'cv::Exception'
  what():  /build/opencv-XZa2gn/opencv-2.3.1/modules/core/src/drawing.cpp:2375: error: (-215) text != 0 && _font != 0 in function cvPutText
Aborted

试试这个,这是一个有效的例子:

char text = 'World';

char buffer[25];
sprintf(buffer, "Hello  %c", text);
CvFont font;
cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 0.5, 0.5);
cvPutText(image, buffer, cvPoint(2, 2), &font, cvScalar(255));

试试这个,这是一个有效的例子:

char text = 'World';

char buffer[25];
sprintf(buffer, "Hello  %c", text);
CvFont font;
cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 0.5, 0.5);
cvPutText(image, buffer, cvPoint(2, 2), &font, cvScalar(255));

<>你把C-API中的定义与C++一个混淆了。 作废cvPutText(CvArr*img、常量字符*text、CvPoint org、常量CvFont*font、CvScalar color)

你需要打电话:


以前

> P>您将C-API中的定义与C++一个混淆了。 作废cvPutText(CvArr*img、常量字符*text、CvPoint org、常量CvFont*font、CvScalar color)

你需要打电话:


以前