;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; LUSH Lisp Universal Shell
;;;   Copyright (C) 2002 Leon Bottou, Yann Le Cun, AT&T Corp, NECI.
;;; Includes parts of TL3:
;;;   Copyright (C) 1987-1999 Leon Bottou and Neuristique.
;;; Includes selected parts of SN3.2:
;;;   Copyright (C) 1991-2001 AT&T Corp.
;;;
;;; Includes information derived from the GSL (Gnu Scientific Library)
;;;   header files which are copyrighted and distributed under the GPL
;;;   by their respective authors.
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(libload "opencv/cv-config")



#? *** posit

;; dummy function that adds OpenCV C header files in C file
(eval `(de dummy_posit () ,cv-cpheader-cmd ()))

;; #? * (dummy_posit)
;; #? * (cvcreatepositobject <points> <npoints>)
;; #? * (cvposit <pobject> <imagepoints> <focallength> <criteria> <rotation> <translation>)
;; #? * (cvreleasepositobject <ppobject>)

;; ********************************************************

;;  /****************************************************************************************\
;;  *                                      POSIT(POse from ITeration)                       *
;;  \****************************************************************************************/

#? (cvCreatePOSITObject  <points> <npoints>)
;;.VP
;;  /*F///////////////////////////////////////////////////////////////////////////////////////
;;  //    Name:       cvCreatePOSITObject
;;  //    Purpose:    Allocate and Initialize CvPOSITObject structure
;;  //                before process cvPOSIT
;;  //    Context:
;;  //    Parameters:
;;  //                  points - pointer to source object points given in
;;  //                           object related coordinate system
;;  //                  numPoints - number of object points
;;  //                  ppObject - address of pointer to CvPOSITObject(returned)
;;  //    Returns:
;;  //    Notes:
;;  //F*/
;;  typedef struct CvPOSITObject CvPOSITObject;
;;  OPENCVAPI  CvPOSITObject*  cvCreatePOSITObject( CvPoint3D32f* points, int numPoints );

(de cvCreatePOSITObject (points npoints)
    ((-gptr- "CvPoint3D32f *") points)
    ((-int-) npoints)
    (let ((s (gptr ())))
      #{ $s = (CvPOSITObject *) cvCreatePOSITObject($points,$npoints); #}
      s))

#? (cvPOSIT  <pobject> <imagepoints> <focallength> <criteria> <rotation> <translation>)
;;.VP
;;  /*F///////////////////////////////////////////////////////////////////////////////////////
;;  //    Name:       cvPOSIT
;;  //    Purpose:    performs POSIT algorithm
;;  //
;;  //    Context:
;;  //    Parameters:
;;  //                  pObject - pointer to CvPOSITObject filled with prev. function
;;  //                  imagePoints - pointer to source object image points given in
;;  //                                camera related coordinate system
;;  //                  focalLength - focal length of camera
;;  //                  criteria - stop criteria.
;;  //                  rotation - rotation matrix
;;  //                  translation - translation vector(from camera to
;;  //                                first point of object )
;;  //    Returns:
;;  //    Notes:
;;  //F*/
;;  OPENCVAPI  void  cvPOSIT(  CvPOSITObject* pObject, CvPoint2D32f* imagePoints,
;;                             double focalLength, CvTermCriteria criteria,
;;                             CvMatr32f rotation, CvVect32f translation);

(de cvPOSIT( pobject imagepoints focallength criteria rotation translation)
    ((-gptr- "CvPOSITObject *") pobject)
    ((-gptr- "CvPoint2D32f *") imagepoints)
    ((-double-) focallength)
    ((-gptr- "CvTermCriteria *") criteria)
    ((-gptr- "CvMatr32f *") rotation)
    ((-gptr- "CvVect32f *") translation)
    #{  cvPOSIT($pobject, $imagepoints, $focallength, *$criteria, *$rotation, *$translation); #}
    ())

#? (cvReleasePOSITObject  <ppobject>)
;;.VP
;;  /*F///////////////////////////////////////////////////////////////////////////////////////
;;  //    Name:       cvReleasePOSITObject
;;  //    Purpose:    free CvPOSITObject structure
;;  //    Context:
;;  //    Parameters:
;;  //      ppObject - address of pointer to CvPOSITObject
;;  //    Returns:
;;  //    Notes:
;;  //F*/
;;  OPENCVAPI  void  cvReleasePOSITObject( CvPOSITObject**  ppObject );

(de cvReleasePOSITObject (ppobject)
    ((-gptr- "CvPOSITObject **") ppobject)
    #{ cvReleasePOSITObject($ppobject); #}
    ())

;; ********************************************************

(dhc-make ()
  dummy_posit
  cvcreatepositobject
  cvposit
  cvreleasepositobject
)
