【OpenCV(C++)】共通データ構造と関数


【OpenCV(C++)】共通データ構造と関数
  • 点の表示:Pointクラス
  • 色の表示:Scalarクラス
  • サイズの表示:Sizeクラス
  • 矩形の表示:Rectクラス
  • 色空間変換:cvtColor()関数
  • 点の表示:Pointクラス
    #include 
    #include 
    #include 
    
    using namespace std;
    using namespace cv;
    
    int main()
    {
    	Point point;
    	point.x = 10;
    	point.y = 8;
    	//or: Point point = Point(10, 8) ;
    
    	cout << "point" << endl << "" << point << endl << endl;
    }
    

    色の表示:Scalarクラス
    カラーパラメータ式:
    Scalar(a, b, c) ;
    

    RGB色の値を定義します.赤成分はc、緑成分はb、青成分はaです.
    寸法の表示:Sizeクラス
    Size(_Tp_width, _Tp_height) ;
    

    矩形の表示:Rectクラス
    Rect rect = rect1 & rect2 ; //        
    Rect rect = rect1 | rect2 ; //  
    Rect rectShift = rect + point ; //  
    Rect rectScale = rect +size ; //  
    

    色空間変換いろくうかんへんかん:cvtColor()関数cvtColor()かんすう
    #include 
    #include 
    #include 
    
    using namespace std;
    using namespace cv;
    
    void main()
    {
    	Mat srcImage = imread("fg.jpg"), dstImage;
    	cvtColor(srcImage, dstImage, COLOR_BGR2Lab);
    	imshow("  ", srcImage);
    	imshow("   ", dstImage);
    	waitKey();
    }
    

    実行効果は次のとおりです.