16acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn/*M///////////////////////////////////////////////////////////////////////////////////////
26acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//
36acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
46acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//
56acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//  By downloading, copying, installing or using the software you agree to this license.
66acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//  If you do not agree to this license, do not download, install,
76acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//  copy or use the software.
86acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//
96acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//
106acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//                        Intel License Agreement
116acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//                For Open Source Computer Vision Library
126acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//
136acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn// Copyright (C) 2000, Intel Corporation, all rights reserved.
146acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn// Third party copyrights are property of their respective owners.
156acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//
166acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn// Redistribution and use in source and binary forms, with or without modification,
176acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn// are permitted provided that the following conditions are met:
186acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//
196acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//   * Redistribution's of source code must retain the above copyright notice,
206acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//     this list of conditions and the following disclaimer.
216acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//
226acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//   * Redistribution's in binary form must reproduce the above copyright notice,
236acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//     this list of conditions and the following disclaimer in the documentation
246acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//     and/or other materials provided with the distribution.
256acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//
266acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//   * The name of Intel Corporation may not be used to endorse or promote products
276acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//     derived from this software without specific prior written permission.
286acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//
296acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn// This software is provided by the copyright holders and contributors "as is" and
306acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn// any express or implied warranties, including, but not limited to, the implied
316acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn// warranties of merchantability and fitness for a particular purpose are disclaimed.
326acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn// In no event shall the Intel Corporation or contributors be liable for any direct,
336acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn// indirect, incidental, special, exemplary, or consequential damages
346acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn// (including, but not limited to, procurement of substitute goods or services;
356acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn// loss of use, data, or profits; or business interruption) however caused
366acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn// and on any theory of liability, whether in contract, strict liability,
376acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn// or tort (including negligence or otherwise) arising in any way out of
386acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn// the use of this software, even if advised of the possibility of such damage.
396acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//
406acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//M*/
416acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn#include "_cvaux.h"
426acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
436acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn#if 0
446acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius RennCvStatus
456acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius RennicvFetchLine8uC3R( uchar * src, int src_step,
466acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                   uchar * dst, int *dst_num, CvSize src_size, CvPoint start, CvPoint end )
476acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn{
486acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    int i;
496acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    int dx = end.x - start.x, dy = end.y - start.y;
506acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    int err;
516acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
526acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    if( !src || !dst || (src_size.width | src_size.height) < 0 ||
536acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        src_step < src_size.width * 3 ||
546acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        (unsigned) start.x >= (unsigned) src_size.width ||
556acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        (unsigned) start.y >= (unsigned) src_size.height ||
566acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        (unsigned) end.x >= (unsigned) src_size.width ||
576acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        (unsigned) end.y >= (unsigned) src_size.height )
586acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        return CV_BADFACTOR_ERR;
596acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
606acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    if( dx < 0 )
616acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    {
626acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        dx = -dx;
636acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        dy = -dy;
646acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        start.x = end.x;
656acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        start.y = end.y;
666acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    }
676acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
686acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    src += start.y * src_step + start.x * 3;
696acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
706acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    i = dy >> 31;
716acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    dy = (dy ^ i) - i;
726acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    src_step = (src_step ^ i) - i;
736acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
746acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    if( dx > dy )
756acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    {
766acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        if( dst_num )
776acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        {
786acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            if( *dst_num <= dx )
796acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                return CV_BADSIZE_ERR;
806acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            *dst_num = dx + 1;
816acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        }
826acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        err = dx;
836acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        dx += dx;
846acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        dy += dy;
856acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        for( i = dx; i >= 0; i -= 2, dst += 3 )
866acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        {
876acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            int mask = (err -= dy) < 0 ? -1 : 0;
886acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
896acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            dst[0] = src[0];
906acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            dst[1] = src[1];
916acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            dst[2] = src[2];
926acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
936acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            err += dx & mask;
946acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            src += (src_step & mask) + 3;
956acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        }
966acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    }
976acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    else
986acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    {
996acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        if( dst_num )
1006acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        {
1016acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            if( *dst_num <= dy )
1026acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                return CV_BADSIZE_ERR;
1036acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            *dst_num = dy + 1;
1046acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        }
1056acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        err = dy;
1066acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        dx += dx;
1076acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        dy += dy;
1086acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        for( i = dy; i >= 0; i -= 2, dst += 3 )
1096acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        {
1106acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            int mask = (err -= dx) < 0 ? -1 : 0;
1116acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
1126acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            dst[0] = src[0];
1136acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            dst[1] = src[1];
1146acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            dst[2] = src[2];
1156acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
1166acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            err += dy & mask;
1176acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            src += src_step + (mask & 3);
1186acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        }
1196acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    }
1206acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    return CV_NO_ERR;
1216acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn}
1226acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
1236acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius RennCvStatus
1246acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius RennicvDrawLine8uC3R( uchar * src, int src_num,
1256acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                  uchar * dst, int dst_step, CvSize dst_size, CvPoint start, CvPoint end )
1266acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn{
1276acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    int i;
1286acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    int dx = end.x - start.x, dy = end.y - start.y;
1296acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    int err;
1306acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
1316acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    if( !src || !dst || (dst_size.width | dst_size.height) < 0 ||
1326acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        dst_step < dst_size.width * 3 ||
1336acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        (unsigned) start.x >= (unsigned) dst_size.width ||
1346acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        (unsigned) start.y >= (unsigned) dst_size.height ||
1356acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        (unsigned) end.x >= (unsigned) dst_size.width ||
1366acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        (unsigned) end.y >= (unsigned) dst_size.height )
1376acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        return CV_BADFACTOR_ERR;
1386acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
1396acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    if( dx < 0 )
1406acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    {
1416acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        dx = -dx;
1426acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        dy = -dy;
1436acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        start.x = end.x;
1446acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        start.y = end.y;
1456acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    }
1466acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
1476acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    dst += start.y * dst_step + start.x * 3;
1486acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
1496acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    i = dy >> 31;
1506acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    dy = (dy ^ i) - i;
1516acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    dst_step = (dst_step ^ i) - i;
1526acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
1536acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    if( dx > dy )
1546acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    {
1556acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        if( (unsigned) (src_num - 1) < (unsigned) dx )
1566acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            return CV_BADSIZE_ERR;
1576acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        err = dx;
1586acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        dx += dx;
1596acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        dy += dy;
1606acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        for( i = dx; i >= 0; i -= 2, src += 3 )
1616acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        {
1626acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            int mask = (err -= dy) < 0 ? -1 : 0;
1636acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
1646acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            dst[0] = src[0];
1656acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            dst[1] = src[1];
1666acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            dst[2] = src[2];
1676acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            err += dx & mask;
1686acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            dst += (dst_step & mask) + 3;
1696acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        }
1706acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    }
1716acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    else
1726acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    {
1736acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        if( (unsigned) (src_num - 1) < (unsigned) dy )
1746acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            return CV_BADSIZE_ERR;
1756acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        err = dy;
1766acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        dx += dx;
1776acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        dy += dy;
1786acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        for( i = dy; i >= 0; i -= 2, src += 3 )
1796acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        {
1806acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            int mask = (err -= dx) < 0 ? -1 : 0;
1816acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
1826acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            dst[0] = src[0];
1836acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            dst[1] = src[1];
1846acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            dst[2] = src[2];
1856acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            err += dy & mask;
1866acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            dst += dst_step + (mask & 3);
1876acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        }
1886acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    }
1896acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    return CV_NO_ERR;
1906acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn}
1916acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn#endif
1926acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
1936acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn/*======================================================================================*/
1946acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
1956acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Rennstatic CvStatus
1966acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius RennicvPreWarpImage8uC3R( int numLines,     /* number of scanlines   */
1976acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                      uchar * src,      /* source image          */
1986acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                      int src_step,     /* line step         */
1996acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                      uchar * dst,      /* dest buffers          */
2006acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                      int *dst_nums,    /* lens of buffer        */
2016acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                      CvSize src_size,  /* image size in pixels */
2026acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                      int *scanlines )  /* scanlines array       */
2036acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn{
2046acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    int k;
2056acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    CvPoint start;
2066acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    CvPoint end;
2076acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    int curr;
2086acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    int curr_dst;
2096acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    CvMat mat;
2106acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2116acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    curr = 0;
2126acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    curr_dst = 0;
2136acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2146acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    cvInitMatHeader( &mat, src_size.height, src_size.width, CV_8UC3, src, src_step );
2156acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2166acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    for( k = 0; k < numLines; k++ )
2176acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    {
2186acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        start.x = scanlines[curr++];
2196acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        start.y = scanlines[curr++];
2206acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2216acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        end.x = scanlines[curr++];
2226acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        end.y = scanlines[curr++];
2236acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2246acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn#ifdef _DEBUG
2256acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        {
2266acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        CvLineIterator iterator;
2276acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        assert( cvInitLineIterator( &mat, start, end, &iterator, 8 ) == dst_nums[k] );
2286acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        }
2296acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn#endif
2306acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        cvSampleLine( &mat, start, end, dst + curr_dst, 8 );
2316acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        curr_dst += dst_nums[k] * 3;
2326acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2336acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    }
2346acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2356acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    return CV_NO_ERR;
2366acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn}
2376acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2386acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2396acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn/*======================================================================================*/
2406acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2416acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Rennstatic CvStatus
2426acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius RennicvPostWarpImage8uC3R( int numLines,    /* number of scanlines  */
2436acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                       uchar * src,     /* source buffers       */
2446acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                       int *src_nums,   /* lens of buffers      */
2456acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                       uchar * dst,     /* dest image           */
2466acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                       int dst_step,    /* dest image step      */
2476acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                       CvSize dst_size, /* dest image size      */
2486acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                       int *scanlines ) /* scanline             */
2496acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn{
2506acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    int i, k;
2516acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    CvPoint start;
2526acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    CvPoint end;
2536acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    int curr;
2546acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    int src_num;
2556acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    int curr_src;
2566acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    CvMat mat;
2576acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    CvLineIterator iterator;
2586acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2596acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    curr = 0;
2606acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    curr_src = 0;
2616acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2626acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    cvInitMatHeader( &mat, dst_size.height, dst_size.width, CV_8UC3, dst, dst_step );
2636acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2646acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    for( k = 0; k < numLines; k++ )
2656acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    {
2666acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        start.x = scanlines[curr++];
2676acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        start.y = scanlines[curr++];
2686acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2696acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        end.x = scanlines[curr++];
2706acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        end.y = scanlines[curr++];
2716acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2726acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        src_num = src_nums[k];
2736acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2746acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        if( cvInitLineIterator( &mat, start, end, &iterator, 8 ) != src_num )
2756acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        {
2766acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            assert(0);
2776acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            return CV_NOTDEFINED_ERR;
2786acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        }
2796acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2806acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        for( i = 0; i < src_num; i++ )
2816acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        {
2826acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            memcpy( iterator.ptr, src + curr_src, 3 );
2836acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            CV_NEXT_LINE_POINT( iterator );
2846acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            curr_src += 3;
2856acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        }
2866acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2876acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn#if 0
2886acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        err = icvDrawLine8uC3R( src + curr_src, /* sourse buffer    */
2896acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                                src_num,        /* len of buffer    */
2906acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                                dst,    /* dest image       */
2916acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                                dst_step,       /* dest image step  */
2926acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                                dst_size,       /* dest image size  */
2936acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                                start,  /* start point      */
2946acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                                end );  /* end point        */
2956acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        curr_src += src_num * 3;
2966acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn#endif
2976acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    }
2986acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
2996acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    return CV_NO_ERR;
3006acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3016acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn}
3026acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3036acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3046acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn/*======================================================================================*/
3056acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3066acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn/*F///////////////////////////////////////////////////////////////////////////////////////
3076acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Name:    icvDeleteMoire8uC3R
3086acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Purpose:
3096acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//      Function deletes moire - replaces black uncovered pixels with their neighboors.
3106acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Context:
3116acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Parameters:
3126acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//      img       - image data
3136acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//      img_step  - distance between lines in bytes
3146acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//      img_size  - width and height of the image in pixels
3156acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Returns:
3166acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//      CV_NO_ERR if all Ok or error code
3176acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Notes:
3186acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//F*/
3196acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Rennstatic CvStatus
3206acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius RennicvDeleteMoire8u( uchar * img, int img_step, CvSize img_size, int cn )
3216acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn{
3226acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    int x, y;
3236acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    uchar *src = img, *dst = img + img_step;
3246acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3256acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    if( !img || img_size.width <= 0 || img_size.height <= 0 || img_step < img_size.width * 3 )
3266acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        return CV_BADFACTOR_ERR;
3276acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3286acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    img_size.width *= cn;
3296acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3306acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    for( y = 1; y < img_size.height; y++, src = dst, dst += img_step )
3316acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    {
3326acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        switch( cn )
3336acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        {
3346acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        case 1:
3356acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            for( x = 0; x < img_size.width; x++ )
3366acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            {
3376acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                if( dst[x] == 0 )
3386acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                    dst[x] = src[x];
3396acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            }
3406acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            break;
3416acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        case 3:
3426acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            for( x = 0; x < img_size.width; x += 3 )
3436acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            {
3446acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                if( dst[x] == 0 && dst[x + 1] == 0 && dst[x + 2] == 0 )
3456acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                {
3466acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                    dst[x] = src[x];
3476acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                    dst[x + 1] = src[x + 1];
3486acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                    dst[x + 2] = src[x + 2];
3496acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                }
3506acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            }
3516acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            break;
3526acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        default:
3536acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            assert(0);
3546acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn            break;
3556acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        }
3566acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    }
3576acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3586acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    return CV_NO_ERR;
3596acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn}
3606acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3616acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3626acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn/*F///////////////////////////////////////////////////////////////////////////////////////
3636acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Name: cvDeleteMoire
3646acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Purpose: The functions delete moire on the image after ViewMorphing
3656acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Context:
3666acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Parameters:  img        - image on which will delete moire
3676acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//
3686acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Notes:
3696acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//F*/
3706acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius RennCV_IMPL void
3716acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius RenncvDeleteMoire( IplImage * img )
3726acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn{
3736acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    uchar *img_data = 0;
3746acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    int img_step = 0;
3756acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    CvSize img_size;
3766acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3776acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    CV_FUNCNAME( "cvDeleteMoire" );
3786acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3796acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    __BEGIN__;
3806acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3816acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    cvGetImageRawData( img, &img_data, &img_step, &img_size );
3826acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3836acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    if( img->nChannels != 1 && img->nChannels != 3 )
3846acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        CV_ERROR( CV_BadNumChannels, "Source image must have 3 channel." );
3856acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    if( img->depth != IPL_DEPTH_8U )
3866acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        CV_ERROR( CV_BadDepth, "Channel depth of source image must be 8." );
3876acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3886acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    CV_CALL( icvDeleteMoire8u( img_data, img_step, img_size, img->nChannels ));
3896acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3906acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    __CLEANUP__;
3916acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    __END__;
3926acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3936acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn}
3946acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3956acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
3966acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn/*F///////////////////////////////////////////////////////////////////////////////////////
3976acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Name: cvPreWarpImage
3986acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Purpose: The functions warp image for next stage of ViewMorphing
3996acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Context:
4006acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Parameters:  img        - initial image (in the beginning)
4016acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//
4026acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Notes:
4036acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//F*/
4046acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius RennCV_IMPL void
4056acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius RenncvPreWarpImage( int numLines,   /* number of scanlines */
4066acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                IplImage * img, /* Source Image       */
4076acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                uchar * dst,    /* dest buffers       */
4086acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                int *dst_nums,  /* lens of buffer     */
4096acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                int *scanlines /* scanlines array    */  )
4106acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn{
4116acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    uchar *img_data = 0;
4126acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    int img_step = 0;
4136acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    CvSize img_size;
4146acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
4156acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    CV_FUNCNAME( "cvPreWarpImage" );
4166acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
4176acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    __BEGIN__;
4186acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
4196acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    cvGetImageRawData( img, &img_data, &img_step, &img_size );
4206acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
4216acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    if( img->nChannels != 3 )
4226acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        CV_ERROR( CV_BadNumChannels, "Source image must have 3 channel." );
4236acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    if( img->depth != IPL_DEPTH_8U )
4246acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        CV_ERROR( CV_BadDepth, "Channel depth of image must be 8." );
4256acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
4266acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    CV_CALL( icvPreWarpImage8uC3R( numLines,    /* number of scanlines  */
4276acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                                   img_data,    /* source image         */
4286acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                                   img_step,    /* line step            */
4296acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                                   dst, /* dest buffers         */
4306acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                                   dst_nums,    /* lens of buffer       */
4316acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                                   img_size,    /* image size in pixels */
4326acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                                   scanlines /* scanlines array      */  ));
4336acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
4346acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    __CLEANUP__;
4356acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    __END__;
4366acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
4376acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn}
4386acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
4396acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
4406acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn/*F///////////////////////////////////////////////////////////////////////////////////////
4416acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Name: cvPostWarpImage
4426acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Purpose: The functions postwarp the image after morphing
4436acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Context:
4446acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Parameters:  img        - initial image (in the beginning)
4456acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//
4466acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//    Notes:
4476acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn//F*/
4486acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius RennCV_IMPL void
4496acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius RenncvPostWarpImage( int numLines,  /* number of scanlines  */
4506acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                 uchar * src,   /* source buffers       */
4516acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                 int *src_nums, /* lens of buffers      */
4526acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                 IplImage * img,        /* dest image           */
4536acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                 int *scanlines /* scanline             */  )
4546acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn{
4556acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    uchar *img_data = 0;
4566acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    int img_step = 0;
4576acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    CvSize img_size;
4586acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
4596acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    CV_FUNCNAME( "cvPostWarpImage" );
4606acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
4616acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    __BEGIN__;
4626acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
4636acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    cvGetImageRawData( img, &img_data, &img_step, &img_size );
4646acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
4656acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    if( img->nChannels != 3 )
4666acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        CV_ERROR( CV_BadNumChannels, "Source image must have 3 channel." );
4676acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    if( img->depth != IPL_DEPTH_8U )
4686acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn        CV_ERROR( CV_BadDepth, "Channel depth of image must be 8." );
4696acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
4706acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    CV_CALL( icvPostWarpImage8uC3R( numLines,   /* number of scanlines   */
4716acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                                    src,        /* source buffers       */
4726acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                                    src_nums,   /* lens of buffers      */
4736acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                                    img_data,   /* dest image           */
4746acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                                    img_step,   /* dest image step      */
4756acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                                    img_size,   /* dest image size      */
4766acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn                                    scanlines /* scanline             */  ));
4776acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
4786acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    __CLEANUP__;
4796acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn    __END__;
4806acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn}
4816acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
4826acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn/* End of file */
4836acb9a7ea3d7564944e12cbc73a857b88c1301eeMarius Renn
484