FaceGen 3 SDKs Reference
Loading...
Searching...
No Matches
fimImgPoints.hpp
1//
2// Copyright (c) 2023 Singular Inversions Inc. (facegen.com)
3// Created: May 29, 2001
4// Authors: Andrew Beatty
5//
6
7#ifndef FIM_IMGPOINTS_HPP
8#define FIM_IMGPOINTS_HPP
9
10#include "fimImg.hpp"
11#include "FgMatrixC.hpp"
12#include "FgMatrixV.hpp"
13#include "matrixCTA.hpp"
14#include "FgTransform.hpp"
15#include "fimImgOps.hpp"
16
17namespace Fg {
18
20{
21 FimImgRgbaUbC img;
22 // A list of all position vectors associated with this image, in PACS:
23 Svec<Vec2F> points;
24
26
27 FimImgPtsRgbaUbC(uint wd,uint ht) : img(wd,ht) {}
28
29 explicit
30 FimImgPtsRgbaUbC(const FimImgRgbaUbC & img) : img(img) {}
31
32 void
33 set(const FimImgRgbaUbC & image)
34 {img=image; points.clear(); }
35
36 // Cuts out the floating-point defined region of an image and scales
37 // separately in X and Y to fit the defined pixel size.
38 // Note that the defined region can extend outside the source image, in
39 // which case the pixels values are interpreted to be zero with zero alpha.
41 cutResizeRcs(
42 FutVect2FC lo, // RCS Upper left corner of source area
43 FutVect2FC hi, // RCS Lower right corner of source area
44 uint width, // Width of destination image.
45 uint height) // Height of destination image.
46 const
47 {
48 FimImgPtsRgbaUbC retval;
49 if (!img.empty())
50 fimCutResizeRcs(lo,hi,width,height,img,retval.img);
51 AxAffine2F xf(Mat22F(lo.x1,hi.x1,lo.x2,hi.x2),Mat22F(0,scast<float>(width),0,scast<float>(height)));
52 for (uint ii=0; ii<points.size(); ii++)
53 retval.points.push_back(xf * points[ii]);
54 return retval;
55 }
56
57 uint
58 addRcs(FutVect2FC rcs)
59 {
60 Vec2F pacs(rcs.x1+0.5f,rcs.x2+0.5f);
61 points.push_back(pacs);
62 return uint(points.size()-1);
63 }
64
66 getRcs(uint n) const
67 {
68 Vec2F pacs = points[n];
69 return FutVect2FC(pacs[0]-0.5f,pacs[1]-0.5f);
70 }
71
73 getOics(uint n) const
74 {return img.rcsToOics(getRcs(n)); }
75};
76
77}
78
79#endif