[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcvd-members] libcvd/cvd vision.h
From: |
Gerhard Reitmayr |
Subject: |
[libcvd-members] libcvd/cvd vision.h |
Date: |
Tue, 02 Aug 2011 22:36:55 +0000 |
CVSROOT: /cvsroot/libcvd
Module name: libcvd
Changes by: Gerhard Reitmayr <gerhard> 11/08/02 22:36:55
Modified files:
cvd : vision.h
Log message:
added warp functions that transforms an image from one camera model
into another one
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/vision.h?cvsroot=libcvd&r1=1.40&r2=1.41
Patches:
Index: vision.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/vision.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- vision.h 22 Apr 2011 14:56:09 -0000 1.40
+++ vision.h 2 Aug 2011 22:36:55 -0000 1.41
@@ -416,6 +416,42 @@
}
}
}
+
+/// warp or unwarps an image according to two camera models.
+template <typename T, typename CAM1, typename CAM2>
+void warp( const SubImage<T> & in, const CAM1 & cam_in, SubImage<T> & out,
const CAM2 & cam_out){
+ const ImageRef size = out.size();
+ for(int y = 0; y < size.y; ++y){
+ for(int x = 0; x < size.x; ++x){
+ TooN::Vector<2> l =
cam_in.project(cam_out.unproject(TooN::makeVector(x,y)));
+ if(l[0] >= 0 && l[0] <= in.size().x - 1 && l[1] >= 0 &&
l[1] <= in.size().y -1){
+ sample(in, l[0], l[1], out[y][x]);
+ } else
+ out[y][x] = T();
+ }
+ }
+}
+
+/// warps or unwarps an image according to two camera models and
+/// returns the result image. The size of the output image needs to be
+/// passed in as well.
+template <typename T, typename CAM1, typename CAM2>
+Image<T> warp( const SubImage<T> & in, const CAM1 & cam_in, const ImageRef &
size, const CAM2 & cam_out){
+ Image<T> result(size);
+ warp(in, cam_in, result, cam_out);
+ return result;
+}
+
+/// warps or unwarps an image according to two camera models and
+/// returns the result image. The size of the output image is the
+/// same as the input image size.
+template <typename T, typename CAM1, typename CAM2>
+Image<T> warp( const SubImage<T> & in, const CAM1 & cam_in, const CAM2 &
cam_out){
+ Image<T> result(in.size());
+ warp(in, cam_in, result, cam_out);
+ return result;
+}
+
#endif
/// flips an image vertically in place.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libcvd-members] libcvd/cvd vision.h,
Gerhard Reitmayr <=