1 /*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 /* $Id: db_utilities_camera.cpp,v 1.3 2011/06/17 14:03:31 mbansal Exp $ */
18
19 #include "db_utilities_camera.h"
20 #include "db_utilities.h"
21 #include <assert.h>
22
23
24
25 /*****************************************************************
26 * Lean and mean begins here *
27 *****************************************************************/
28
db_Approx3DCalMat(double K[9],double Kinv[9],int im_width,int im_height,double f_correction,int field)29 void db_Approx3DCalMat(double K[9],double Kinv[9],int im_width,int im_height,double f_correction,int field)
30 {
31 double iw,ih,av_size,field_fact;
32
33 if(field) field_fact=2.0;
34 else field_fact=1.0;
35
36 iw=(double)im_width;
37 ih=(double)(im_height*field_fact);
38 av_size=(iw+ih)/2.0;
39 K[0]=f_correction*av_size;
40 K[1]=0;
41 K[2]=iw/2.0;
42 K[3]=0;
43 K[4]=f_correction*av_size/field_fact;
44 K[5]=ih/2.0/field_fact;
45 K[6]=0;
46 K[7]=0;
47 K[8]=1;
48
49 db_InvertCalibrationMatrix(Kinv,K);
50 }
51