Exemplo n.º 1
0
        /**
         * 格納しているマーカパターンをエンコードして、マーカデータを返します。
         * @param o_out
         * @return
         * 成功すればマーカの方位を返却します。失敗すると-1を返します。
         */

        public int encode(NyIdMarkerPattern o_out)
        {
            int d = getDirection();

            if (d < 0)
            {
                return(-1);
            }
            //回転ビットの取得
            getRotatedBits(d, o_out.data);
            int model = this._model;

            //周辺ビットの取得
            o_out.model = model;
            int control_bits = getControlValue(model, o_out.data);

            o_out.check       = getCheckValue(model, o_out.data);
            o_out.ctrl_mask   = control_bits % 5;
            o_out.ctrl_domain = control_bits / 5;
            if (o_out.ctrl_domain != 0 || o_out.ctrl_mask != 0)
            {
                return(-1);
            }
            //マスク解除処理を実装すること
            return(d);
        }
Exemplo n.º 2
0
        /**
         * i_imageから、idマーカを読みだします。
         * o_dataにはマーカデータ、o_paramにはまーかのパラメータを返却します。
         * @param image
         * @param i_square
         * @param o_data
         * @param o_param
         * @return
         * @throws NyARException
         */
        public bool pickFromRaster(INyARRgbRaster image, NyARIntPoint2d[] i_vertex, NyIdMarkerPattern o_data, NyIdMarkerParam o_param)
        {
            //遠近法のパラメータを計算
            if (!this._perspective_reader.setSourceSquare(i_vertex))
            {
                return(false);
            }
            ;

            INyARRgbPixelReader reader      = image.getRgbPixelReader();
            NyARIntSize         raster_size = image.getSize();


            PerspectivePixelReader.TThreshold th = this.__pickFromRaster_th;
            MarkerPattEncoder encoder            = this.__pickFromRaster_encoder;

            //マーカパラメータを取得
            this._perspective_reader.detectThresholdValue(reader, raster_size, th);

            if (!this._perspective_reader.readDataBits(reader, raster_size, th, encoder))
            {
                return(false);
            }
            int d = encoder.encode(o_data);

            if (d < 0)
            {
                return(false);
            }
            o_param.direction = d;
            o_param.threshold = th.th;

            return(true);
        }
 public bool encode(NyIdMarkerPattern i_data, INyIdMarkerData o_dest)
 {
     NyIdMarkerData_RawBit dest = (NyIdMarkerData_RawBit)o_dest;
     if (i_data.ctrl_domain != _DOMAIN_ID)
     {
         return false;
     }
     //パケット数計算
     int resolution_len = (i_data.model + 1);
     int packet_length = (resolution_len * resolution_len) / 8 + 1;
     int sum = 0;
     for (int i = 0; i < packet_length; i++)
     {
         dest.packet[i] = i_data.data[i];
         sum += i_data.data[i];
     }
     //チェックドット値計算
     sum = sum % _mod_data[i_data.model - 2];
     //チェックドット比較
     if (i_data.check != sum)
     {
         return false;
     }
     dest.length = packet_length;
     return true;
 }
        public bool encode(NyIdMarkerPattern i_data, INyIdMarkerData o_dest)
        {
            NyIdMarkerData_RawBit dest = (NyIdMarkerData_RawBit)o_dest;

            if (i_data.ctrl_domain != _DOMAIN_ID)
            {
                return(false);
            }
            //パケット数計算
            int resolution_len = (i_data.model + i_data.model - 1);        //データドットの数
            int packet_length  = (resolution_len * resolution_len) / 8 + 1;
            int sum            = 0;

            for (int i = 0; i < packet_length; i++)
            {
                dest.packet[i] = i_data.data[i];
                sum           += i_data.data[i];
            }
            //チェックドット値計算
            sum = sum % _mod_data[i_data.model - 2];
            //チェックドット比較
            if (i_data.check != sum)
            {
                return(false);
            }
            dest.length = packet_length;
            return(true);
        }
 /**
  * この関数は、ラスタドライバから画像を読み出します。
  * @param i_pix_drv
  * @param i_size
  * @param i_vertex
  * @param o_data
  * @param o_param
  * @return
  * @
  */
 public bool pickFromRaster(INyARGsPixelDriver i_pix_drv, NyARIntPoint2d[] i_vertex, NyIdMarkerPattern o_data, NyIdMarkerParam o_param)
 {
     if (!this._perspective_reader.setSourceSquare(i_vertex))
     {
         return false;
     }
     return this._pickFromRaster(i_pix_drv, o_data, o_param);
 }
Exemplo n.º 6
0
 /**
  * imageの4頂点で囲まれた矩形からidマーカを読みだします。
  * @param image
  * @param i_vertex
  * @param o_data
  * @param o_param
  * @return
  * @throws NyARException
  */
 public bool pickFromRaster(INyARRgbRaster image, NyARIntPoint2d[] i_vertex, NyIdMarkerPattern o_data, NyIdMarkerParam o_param)
 {
     if (!this._perspective_reader.setSourceSquare(i_vertex))
     {
         return(false);
     }
     return(this._pickFromRaster(image, o_data, o_param));
 }
Exemplo n.º 7
0
        /**
         * i_imageから、idマーカを読みだします。
         * o_dataにはマーカデータ、o_paramにはマーカのパラメータを返却します。
         * @param image
         * @param i_vertex
         * @param o_data
         * @param o_param
         * @return
         * @
         */
        private bool _pickFromRaster(INyARGsPixelDriver i_pix_drv, NyIdMarkerPattern o_data, NyIdMarkerParam o_param)
        {
            PerspectivePixelReader.TThreshold th = this.__pickFromRaster_th;
            MarkerPattEncoder encoder            = this.__pickFromRaster_encoder;

            //マーカパラメータを取得
            this._perspective_reader.detectThresholdValue(i_pix_drv, th);

            if (!this._perspective_reader.readDataBits(i_pix_drv, i_pix_drv.getSize(), th, encoder))
            {
                return(false);
            }
            int d = encoder.encode(o_data);

            if (d < 0)
            {
                return(false);
            }
            o_param.direction = d;
            o_param.threshold = th.th;

            return(true);
        }
Exemplo n.º 8
0
 /**
  * この関数は、ラスタドライバから画像を読み出します。
  * @param i_pix_drv
  * @param i_size
  * @param i_vertex
  * @param o_data
  * @param o_param
  * @return
  * @
  */
 public bool pickFromRaster(INyARGsPixelDriver i_pix_drv, NyARDoublePoint2d[] i_vertex, NyIdMarkerPattern o_data, NyIdMarkerParam o_param)
 {
     if (!this._perspective_reader.setSourceSquare(i_vertex))
     {
         return(false);
     }
     return(this._pickFromRaster(i_pix_drv, o_data, o_param));
 }
        /**
         * i_imageから、idマーカを読みだします。
         * o_dataにはマーカデータ、o_paramにはまーかのパラメータを返却します。
         * @param image
         * @param i_square
         * @param o_data
         * @param o_param
         * @return
         * @throws NyARException
         */
        public bool pickFromRaster(INyARRgbRaster image, NyARIntPoint2d[] i_vertex, NyIdMarkerPattern o_data, NyIdMarkerParam o_param)
        {
            //遠近法のパラメータを計算
            if (!this._perspective_reader.setSourceSquare(i_vertex))
            {
                return false;
            };

            INyARRgbPixelReader reader = image.getRgbPixelReader();
            NyARIntSize raster_size = image.getSize();


            PerspectivePixelReader.TThreshold th = this.__pickFromRaster_th;
            MarkerPattEncoder encoder = this.__pickFromRaster_encoder;
            //マーカパラメータを取得
            this._perspective_reader.detectThresholdValue(reader, raster_size, th);

            if (!this._perspective_reader.readDataBits(reader, raster_size,th, encoder))
            {
                return false;
            }
            int d = encoder.encode(o_data);
            if (d < 0)
            {
                return false;
            }
            o_param.direction = d;
            o_param.threshold = th.th;

            return true;
        }
Exemplo n.º 10
0
        /**
         * 格納しているマーカパターンをエンコードして、マーカデータを返します。
         * @param o_out
         * @return
         * 成功すればマーカの方位を返却します。失敗すると-1を返します。
         */

        public int encode(NyIdMarkerPattern o_out)
        {
            int d = getDirection();
            if (d < 0)
            {
                return -1;
            }
            //回転ビットの取得
            getRotatedBits(d, o_out.data);
            int model = this._model;
            //周辺ビットの取得
            o_out.model = model;
            int control_bits = getControlValue(model, o_out.data);
            o_out.check = getCheckValue(model, o_out.data);
            o_out.ctrl_mask = control_bits % 5;
            o_out.ctrl_domain = control_bits / 5;
            if (o_out.ctrl_domain != 0 || o_out.ctrl_mask != 0)
            {
                return -1;
            }
            //マスク解除処理を実装すること
            return d;
        }
Exemplo n.º 11
0
        /**
         * i_imageから、idマーカを読みだします。
         * o_dataにはマーカデータ、o_paramにはマーカのパラメータを返却します。
         * @param image
         * @param i_vertex
         * @param o_data
         * @param o_param
         * @return
         * @
         */
        private bool _pickFromRaster(INyARGsPixelDriver i_pix_drv, NyIdMarkerPattern o_data, NyIdMarkerParam o_param)
        {
            PerspectivePixelReader.TThreshold th = this.__pickFromRaster_th;
            MarkerPattEncoder encoder = this.__pickFromRaster_encoder;
            //マーカパラメータを取得
            this._perspective_reader.detectThresholdValue(i_pix_drv, th);

            if (!this._perspective_reader.readDataBits(i_pix_drv, i_pix_drv.getSize(), th, encoder))
            {
                return false;
            }
            int d = encoder.encode(o_data);
            if (d < 0)
            {
                return false;
            }
            o_param.direction = d;
            o_param.threshold = th.th;

            return true;
        }