GR-SAKURA
GR-KURUMI
GR-COTTON
GR-CITRUS
GR-PEACH
GR-KAEDE
GR-ADZUKI
GR-LYCHEE
GR-ROSE
GR-MANGO(*)
SNShield
Web Compiler
IDE for GR
TOPPERS関連
女子美コラボ
その他
※プロデューサミーティング中
作り方使い方資料
イベント関連
作品記事
体験記事
ライブラリ
ツール
その他・過去ファイル
初めまして。
IDE4GRV1.03(Mac)です。
FaceDetection_Display_LCDにStringを宣言しようとしたところ
error: reference to 'String' is ambiguous
とのエラーでした。複数のインクルードファイルでダブっているのでしょうか。
どのような対応をすれな良いでしょうか。
FaceDetection_Display_LCD2.ino: In function 'void loop()':FaceDetection_Display_LCD2.ino:60:1: error: reference to 'String' is ambiguousIn file included from /Applications/IDE4GR.app/Contents/Java/hardware/arduino/rza1lu/cores/arduino/cores/Arduino.h:321:0, from FaceDetection_Display_LCD2.ino:5:/Applications/IDE4GR.app/Contents/Java/hardware/arduino/rza1lu/cores/arduino/cores/WString.h:52:7: note: candidates are: class String class String ^In file included from /Applications/IDE4GR.app/Contents/Java/hardware/arduino/rza1lu/cores/opencv-lib/include/opencv2/core/base.hpp:58:0, from /Applications/IDE4GR.app/Contents/Java/hardware/arduino/rza1lu/cores/opencv-lib/include/opencv2/core.hpp:54, from /Applications/IDE4GR.app/Contents/Java/hardware/arduino/rza1lu/cores/opencv-lib/include/opencv2/opencv.hpp:52, from FaceDetection_Display_LCD2.ino:8:/Applications/IDE4GR.app/Contents/Java/hardware/arduino/rza1lu/cores/opencv-lib/include/opencv2/core/cvstd.hpp:477:18: note: class cv::String class CV_EXPORTS String ^FaceDetection_Display_LCD2.ino:61:1: error: reference to 'String' is ambiguousIn file included from /Applications/IDE4GR.app/Contents/Java/hardware/arduino/rza1lu/cores/arduino/cores/Arduino.h:321:0, from FaceDetection_Display_LCD2.ino:5:/Applications/IDE4GR.app/Contents/Java/hardware/arduino/rza1lu/cores/arduino/cores/WString.h:52:7: note: candidates are: class String class String ^In file included from /Applications/IDE4GR.app/Contents/Java/hardware/arduino/rza1lu/cores/opencv-lib/include/opencv2/core/base.hpp:58:0, from /Applications/IDE4GR.app/Contents/Java/hardware/arduino/rza1lu/cores/opencv-lib/include/opencv2/core.hpp:54, from /Applications/IDE4GR.app/Contents/Java/hardware/arduino/rza1lu/cores/opencv-lib/include/opencv2/opencv.hpp:52, from FaceDetection_Display_LCD2.ino:8:/Applications/IDE4GR.app/Contents/Java/hardware/arduino/rza1lu/cores/opencv-lib/include/opencv2/core/cvstd.hpp:477:18: note: class cv::String class CV_EXPORTS String ^FaceDetection_Display_LCD2.ino:65:34: error: invalid types 'char [32][<unresolved overloaded function type>]' for array subscriptFaceDetection_Display_LCD2.ino:68:7: error: reference to 'String' is ambiguousIn file included from /Applications/IDE4GR.app/Contents/Java/hardware/arduino/rza1lu/cores/arduino/cores/Arduino.h:321:0, from FaceDetection_Display_LCD2.ino:5:/Applications/IDE4GR.app/Contents/Java/hardware/arduino/rza1lu/cores/arduino/cores/WString.h:52:7: note: candidates are: class String class String ^In file included from /Applications/IDE4GR.app/Contents/Java/hardware/arduino/rza1lu/cores/opencv-lib/include/opencv2/core/base.hpp:58:0, from /Applications/IDE4GR.app/Contents/Java/hardware/arduino/rza1lu/cores/opencv-lib/include/opencv2/core.hpp:54, from /Applications/IDE4GR.app/Contents/Java/hardware/arduino/rza1lu/cores/opencv-lib/include/opencv2/opencv.hpp:52, from FaceDetection_Display_LCD2.ino:8:/Applications/IDE4GR.app/Contents/Java/hardware/arduino/rza1lu/cores/opencv-lib/include/opencv2/core/cvstd.hpp:477:18: note: class cv::String class CV_EXPORTS String ^FaceDetection_Display_LCD2.ino:70:20: error: 'Rdata' was not declared in this scopeFaceDetection_Display_LCD2.ino:71:7: error: 'major' was not declared in this scopeFaceDetection_Display_LCD2.ino:72:7: error: 'minor' was not declared in this scope
namespace cvを取り、以下のようにOpenCV関連のものにcv::をつけて明示するようにしていただけますか?
Loop()のはじめにString sを入れてコンパイルエラーが発生しないことだけ確認してます。
#include <Arduino.h>#include <Camera.h>#include <LCD.h>#include <opencv.hpp>#include "SdUsbConnect.h"#define IMAGE_HW 480#define IMAGE_VW 272/* FACE DETECTOR Parameters */#define DETECTOR_SCALE_FACTOR (2)#define DETECTOR_MIN_NEIGHBOR (4)#define DETECTOR_MIN_SIZE (30)#define FACE_DETECTOR_MODEL "/storage/lbpcascade_frontalface.xml"static Camera camera(IMAGE_HW, IMAGE_VW);static LCD lcd(IMAGE_HW, IMAGE_VW);static cv::CascadeClassifier detector_classifier;static uint8_t lcd_buf[IMAGE_HW * IMAGE_VW * 2]; // 2 bytes per pixelvoid setup() { pinMode(PIN_LED_GREEN, OUTPUT); pinMode(PIN_LED_RED, OUTPUT); // SD & USB SdUsbConnect storage("storage"); storage.wait_connect(); // Load the cascade classifier file detector_classifier.load(FACE_DETECTOR_MODEL); if (detector_classifier.empty()) { digitalWrite(PIN_LED_RED, HIGH); // Error CV_Assert(0); mbed_die(); } // Camera camera.begin(); // LCD lcd.begin(lcd_buf, IMAGE_HW, IMAGE_VW); lcd.clear();}void loop(){ String s; cv::Mat img_raw(IMAGE_VW, IMAGE_HW, CV_8UC2, camera.getImageAdr()); cv::Mat src; cv::cvtColor(img_raw, src, cv::COLOR_YUV2GRAY_YUYV); //covert from YUV to GRAY // Detect a face in the frame cv::Rect face_roi; if (detector_classifier.empty()) { digitalWrite(PIN_LED_RED, HIGH); // Error } // Perform detected the biggest face std::vector<cv::Rect> rect_faces; detector_classifier.detectMultiScale(src, rect_faces, DETECTOR_SCALE_FACTOR, DETECTOR_MIN_NEIGHBOR, cv::CASCADE_FIND_BIGGEST_OBJECT, cv::Size(DETECTOR_MIN_SIZE, DETECTOR_MIN_SIZE)); if (rect_faces.size() > 0) { // A face is detected face_roi = rect_faces[0]; } else { // No face is detected, set an invalid rectangle face_roi.x = -1; face_roi.y = -1; face_roi.width = -1; face_roi.height = -1; } if (face_roi.width > 0 && face_roi.height > 0) { // A face is detected digitalWrite(PIN_LED_GREEN, HIGH); printf("Detected a face X:%d Y:%d W:%d H:%d\n",face_roi.x, face_roi.y, face_roi.width, face_roi.height); digitalWrite(PIN_LED_GREEN, LOW); } else { } cv::rectangle(src, cv::Point(face_roi.x, face_roi.y), cv::Point(face_roi.x + face_roi.width, face_roi.y + face_roi.height), 255, 2); lcd.GRAY2YUV(src.data, lcd_buf, IMAGE_HW, IMAGE_VW);}