を表示しない、私は、楕円を描くことCV ::スカラー画像フレームに期待色
void ellipse(Mat& img, Point center, Size axes, double angle, double startAngle, double endAngle, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
を使用し、私は緑色 [RGB値に楕円の色を設定する(165、206 、94)]。 は、だから、私はまた、RGBの代替を試してみました
cv::Scalar(94.0, 206.0, 165.0, 0.0); // as BGR order, suppose the value is 0.0 - 255.0
cv::Scalar(94.0/255.0, 206.0/255.0, 165.0/255.0, 0.0); // suppose the value is 0.0 - 1.0
にパラメータconst Scalar& color
を設定します。
CV_RGB(165.0, 206.0, 94.0); // as RGB order, suppose the value is 0.0 - 255.0
CV_RGB(165.0/255.0, 206.0/255.0, 94.0/255.0); // suppose the value is 0.0 - 1.0
しかし、表示される色が[RGB値(255、255、255)]ではなく、所望の緑の白です。
私はこの時点で迷ったことはありますか?どんな提案もお願いします。ありがとうございました。
EDIT:
私はここで全体の関連するコードを入れてみましょう。
self.videoCamera = [[CvVideoCamera alloc] initWithParentView:imgView];
[self.videoCamera setDelegate:self];
self.videoCamera.defaultAVCaptureDevicePosition = AVCaptureDevicePositionFront;
self.videoCamera.defaultAVCaptureSessionPreset = AVCaptureSessionPreset352x288;
self.videoCamera.defaultAVCaptureVideoOrientation = AVCaptureVideoOrientationPortrait;
self.videoCamera.defaultFPS = 30;
self.videoCamera.grayscaleMode = NO;
[self.videoCamera adjustLayoutToInterfaceOrientation:UIInterfaceOrientationPortrait];
が続い呼ば[self.videoCamera start];
後、(Mat&)image
がキャプチャされるだろうとCvVideoCameraDelegate方法- (void)processImage:(Mat&)image;
で処理することができ、ここで楕円を描くためのコードです:
- (void)viewDidLoad;
で
CvVideoCamera
configがあります
- (void)processImage:(Mat&)image {
NSLog(@"image.type(): %d", image.type()); // got 24
// image.convertTo(image, CV_8UC3); // try to convert image type, but with or without this line result the same
NSLog(@"image.type(): %d", image.type()); // also 24
cv::Scalar colorScalar = cv::Scalar(94, 206, 165);
cv::Point center(image.size().width*0.5, image.size().height*0.5);
cv::Size size(100, 100);
cv::ellipse(image, center, size, 0, 0, 360, colorScalar, 4, 8, 0);
}
は、最終的に、楕円は白ではなく、所望の緑の中です。
コードの残りの部分を確認し、他の場所で色の値を変更していないことを確認してください。あなたが提供した部分は私のマシンに期待される緑の色を完全に示しています。 – Barshan
多分あなたはフロートタイプの画像を持っていますか? [0 1]値の範囲は? – mrgloom
@Barshan Das私はコードの残りの部分をチェックしコメントしましたが、色は変わりません。どちらがあなたのために働いていますか? – Protocole