Android Open Source - android-opencv-template Point






From Project

Back to project page android-opencv-template.

License

The source code is released under:

MIT License

If you think the Android project android-opencv-template listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.opencv.core;
//  ww  w  . j  a  v a 2 s. co m
/**
 * <p>template<typename _Tp> class CV_EXPORTS Point_ <code></p>
 *
 * <p>// C++ code:</p>
 *
 *
 * <p>public:</p>
 *
 * <p>typedef _Tp value_type;</p>
 *
 * <p>// various constructors</p>
 *
 * <p>Point_();</p>
 *
 * <p>Point_(_Tp _x, _Tp _y);</p>
 *
 * <p>Point_(const Point_& pt);</p>
 *
 * <p>Point_(const CvPoint& pt);</p>
 *
 * <p>Point_(const CvPoint2D32f& pt);</p>
 *
 * <p>Point_(const Size_<_Tp>& sz);</p>
 *
 * <p>Point_(const Vec<_Tp, 2>& v);</p>
 *
 * <p>Point_& operator = (const Point_& pt);</p>
 *
 * <p>//! conversion to another data type</p>
 *
 * <p>template<typename _Tp2> operator Point_<_Tp2>() const;</p>
 *
 * <p>//! conversion to the old-style C structures</p>
 *
 * <p>operator CvPoint() const;</p>
 *
 * <p>operator CvPoint2D32f() const;</p>
 *
 * <p>operator Vec<_Tp, 2>() const;</p>
 *
 * <p>//! dot product</p>
 *
 * <p>_Tp dot(const Point_& pt) const;</p>
 *
 * <p>//! dot product computed in double-precision arithmetics</p>
 *
 * <p>double ddot(const Point_& pt) const;</p>
 *
 * <p>//! cross-product</p>
 *
 * <p>double cross(const Point_& pt) const;</p>
 *
 * <p>//! checks whether the point is inside the specified rectangle</p>
 *
 * <p>bool inside(const Rect_<_Tp>& r) const;</p>
 *
 * <p>_Tp x, y; //< the point coordinates</p>
 *
 * <p>};</p>
 *
 * <p>Template class for 2D points specified by its coordinates </code></p>
 *
 * <p><em>x</em> and <em>y</em>.
 * An instance of the class is interchangeable with C structures,
 * <code>CvPoint</code> and <code>CvPoint2D32f</code>. There is also a cast
 * operator to convert point coordinates to the specified type. The conversion
 * from floating-point coordinates to integer coordinates is done by rounding.
 * Commonly, the conversion uses thisoperation for each of the coordinates.
 * Besides the class members listed in the declaration above, the following
 * operations on points are implemented: <code></p>
 *
 * <p>// C++ code:</p>
 *
 * <p>pt1 = pt2 + pt3;</p>
 *
 * <p>pt1 = pt2 - pt3;</p>
 *
 * <p>pt1 = pt2 * a;</p>
 *
 * <p>pt1 = a * pt2;</p>
 *
 * <p>pt1 += pt2;</p>
 *
 * <p>pt1 -= pt2;</p>
 *
 * <p>pt1 *= a;</p>
 *
 * <p>double value = norm(pt); // L2 norm</p>
 *
 * <p>pt1 == pt2;</p>
 *
 * <p>pt1 != pt2;</p>
 *
 * <p>For your convenience, the following type aliases are defined:</p>
 *
 * <p>typedef Point_<int> Point2i;</p>
 *
 * <p>typedef Point2i Point;</p>
 *
 * <p>typedef Point_<float> Point2f;</p>
 *
 * <p>typedef Point_<double> Point2d;</p>
 *
 * <p>Example:</p>
 *
 * <p>Point2f a(0.3f, 0.f), b(0.f, 0.4f);</p>
 *
 * <p>Point pt = (a + b)*10.f;</p>
 *
 * <p>cout << pt.x << ", " << pt.y << endl;</p>
 *
 * @see <a href="http://docs.opencv.org/modules/core/doc/basic_structures.html#point">org.opencv.core.Point_</a>
 */
public class Point {

    public double x, y;

    public Point(double x, double y) {
        this.x = x;
        this.y = y;
    }

    public Point() {
        this(0, 0);
    }

    public Point(double[] vals) {
        this();
        set(vals);
    }

    public void set(double[] vals) {
        if (vals != null) {
            x = vals.length > 0 ? vals[0] : 0;
            y = vals.length > 1 ? vals[1] : 0;
        } else {
            x = 0;
            y = 0;
        }
    }

    public Point clone() {
        return new Point(x, y);
    }

    public double dot(Point p) {
        return x * p.x + y * p.y;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        long temp;
        temp = Double.doubleToLongBits(x);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        temp = Double.doubleToLongBits(y);
        result = prime * result + (int) (temp ^ (temp >>> 32));
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (!(obj instanceof Point)) return false;
        Point it = (Point) obj;
        return x == it.x && y == it.y;
    }

    public boolean inside(Rect r) {
        return r.contains(this);
    }

    @Override
    public String toString() {
        return "{" + x + ", " + y + "}";
    }
}




Java Source Code List

com.floatlearning.android_opencv_template.MainActivity.java
org.opencv.android.AsyncServiceHelper.java
org.opencv.android.BaseLoaderCallback.java
org.opencv.android.CameraBridgeViewBase.java
org.opencv.android.FpsMeter.java
org.opencv.android.InstallCallbackInterface.java
org.opencv.android.JavaCameraView.java
org.opencv.android.LoaderCallbackInterface.java
org.opencv.android.NativeCameraView.java
org.opencv.android.OpenCVLoader.java
org.opencv.android.StaticHelper.java
org.opencv.android.Utils.java
org.opencv.calib3d.Calib3d.java
org.opencv.calib3d.StereoBM.java
org.opencv.calib3d.StereoSGBM.java
org.opencv.contrib.Contrib.java
org.opencv.contrib.FaceRecognizer.java
org.opencv.contrib.StereoVar.java
org.opencv.core.Algorithm.java
org.opencv.core.Core.java
org.opencv.core.CvException.java
org.opencv.core.CvType.java
org.opencv.core.MatOfByte.java
org.opencv.core.MatOfDMatch.java
org.opencv.core.MatOfDouble.java
org.opencv.core.MatOfFloat4.java
org.opencv.core.MatOfFloat6.java
org.opencv.core.MatOfFloat.java
org.opencv.core.MatOfInt4.java
org.opencv.core.MatOfInt.java
org.opencv.core.MatOfKeyPoint.java
org.opencv.core.MatOfPoint2f.java
org.opencv.core.MatOfPoint3.java
org.opencv.core.MatOfPoint3f.java
org.opencv.core.MatOfPoint.java
org.opencv.core.MatOfRect.java
org.opencv.core.Mat.java
org.opencv.core.Point3.java
org.opencv.core.Point.java
org.opencv.core.Range.java
org.opencv.core.Rect.java
org.opencv.core.RotatedRect.java
org.opencv.core.Scalar.java
org.opencv.core.Size.java
org.opencv.core.TermCriteria.java
org.opencv.features2d.DMatch.java
org.opencv.features2d.DescriptorExtractor.java
org.opencv.features2d.DescriptorMatcher.java
org.opencv.features2d.FeatureDetector.java
org.opencv.features2d.Features2d.java
org.opencv.features2d.GenericDescriptorMatcher.java
org.opencv.features2d.KeyPoint.java
org.opencv.gpu.DeviceInfo.java
org.opencv.gpu.Gpu.java
org.opencv.gpu.TargetArchs.java
org.opencv.highgui.Highgui.java
org.opencv.highgui.VideoCapture.java
org.opencv.imgproc.CLAHE.java
org.opencv.imgproc.Imgproc.java
org.opencv.imgproc.Moments.java
org.opencv.imgproc.Subdiv2D.java
org.opencv.ml.CvANN_MLP_TrainParams.java
org.opencv.ml.CvANN_MLP.java
org.opencv.ml.CvBoostParams.java
org.opencv.ml.CvBoost.java
org.opencv.ml.CvDTreeParams.java
org.opencv.ml.CvDTree.java
org.opencv.ml.CvERTrees.java
org.opencv.ml.CvGBTreesParams.java
org.opencv.ml.CvGBTrees.java
org.opencv.ml.CvKNearest.java
org.opencv.ml.CvNormalBayesClassifier.java
org.opencv.ml.CvParamGrid.java
org.opencv.ml.CvRTParams.java
org.opencv.ml.CvRTrees.java
org.opencv.ml.CvSVMParams.java
org.opencv.ml.CvSVM.java
org.opencv.ml.CvStatModel.java
org.opencv.ml.EM.java
org.opencv.ml.Ml.java
org.opencv.objdetect.CascadeClassifier.java
org.opencv.objdetect.HOGDescriptor.java
org.opencv.objdetect.Objdetect.java
org.opencv.photo.Photo.java
org.opencv.utils.Converters.java
org.opencv.video.BackgroundSubtractorMOG2.java
org.opencv.video.BackgroundSubtractorMOG.java
org.opencv.video.BackgroundSubtractor.java
org.opencv.video.KalmanFilter.java
org.opencv.video.Video.java