00001 #include "Shot.h"
00002 #include "Sensor.h"
00003 #include "linux/mt9p031.h"
00004 #include <algorithm>
00005
00006 namespace FCam{ namespace F2{
00007
00008 Shot::Shot(): FCam::Shot(),
00009 rowSkip(RowSkip::none), colSkip(ColSkip::none),
00010 rowBin(RowBin::none), colBin(ColBin::none),
00011 roiCentered(false), roiStartX(0), roiStartY(0)
00012 {
00013 }
00014
00015 Shot::Shot(const FCam::Shot &shot): FCam::Shot(shot) {
00016
00017
00018 roiRegionSmaller(Sensor::activeArrayRect());
00019 }
00020
00021 Shot::Shot(const Shot &other): FCam::Shot(static_cast<const FCam::Shot&>(other)),
00022 rowSkip(other.rowSkip),
00023 colSkip(other.colSkip),
00024 rowBin(other.rowBin),
00025 colBin(other.colBin),
00026 roiCentered(other.roiCentered),
00027 roiStartX(other.roiStartX),
00028 roiStartY(other.roiStartY)
00029 {
00030
00031
00032 }
00033
00034 const Shot &Shot::operator=(const FCam::Shot &other) {
00035 FCam::Shot::operator=(other);
00036
00037 roiRegionSmaller(Sensor::activeArrayRect());
00038
00039 return *this;
00040 }
00041
00042 const Shot &Shot::operator=(const Shot &other) {
00043 FCam::Shot::operator=(static_cast<const FCam::Shot&>(other));
00044
00045 rowSkip = other.rowSkip;
00046 colSkip = other.colSkip;
00047 rowBin = other.rowBin;
00048 colBin = other.colBin;
00049
00050 roiCentered = other.roiCentered;
00051 roiStartX = other.roiStartX;
00052 roiStartY = other.roiStartY;
00053
00054 return *this;
00055 }
00056
00057 void Shot::roiRegionSmaller(const Rect &maxRegion, bool useBinning) {
00058
00059
00060 int scaleX = maxRegion.width / image.size.width;
00061 int scaleY = maxRegion.height / image.size.height;
00062
00063 scaleX = std::max(1, std::min(scaleX, 7));
00064 scaleY = std::max(1, std::min(scaleY, 8));
00065
00066 colSkip = static_cast<ColSkip::e>(scaleX);
00067 rowSkip = static_cast<RowSkip::e>(scaleY);
00068
00069 if (useBinning) {
00070 int binX = std::max(1, std::min(scaleX, 4));
00071 int binY = std::max(1, std::min(scaleY, 4));
00072
00073 if (binX == 3) binX = 2;
00074
00075 colBin = static_cast<ColBin::e>(binX);
00076 rowBin = static_cast<RowBin::e>(binY);
00077 } else {
00078 colBin = ColBin::none;
00079 rowBin = RowBin::none;
00080 }
00081
00082 roiCentered = false;
00083 roiStartX = maxRegion.x;
00084 roiStartY = maxRegion.y;
00085 }
00086
00087 void Shot::roiRegionSmaller(const Size &maxSize, bool useBinning) {
00088 FCam::Rect region(0,0, maxSize.width, maxSize.height);
00089 roiRegionSmaller(region, useBinning);
00090 }
00091
00092 void Shot::roiRegionLarger(const Rect &minRegion, bool useBinning) {
00093
00094
00095 int scaleX = (minRegion.width / image.size.width) + 1;
00096 int scaleY = (minRegion.height / image.size.height) + 1;
00097
00098 scaleX = std::max(1, std::min(scaleX, 7));
00099 scaleY = std::max(1, std::min(scaleY, 8));
00100
00101 colSkip = static_cast<ColSkip::e>(scaleX);
00102 rowSkip = static_cast<RowSkip::e>(scaleY);
00103
00104 if (useBinning) {
00105 int binX = std::max(1, std::min(scaleX, 4));
00106 int binY = std::max(1, std::min(scaleY, 4));
00107
00108 if (binX == 3) {
00109 binX = 4;
00110 colSkip = ColSkip::x4;
00111 }
00112
00113 colBin = static_cast<ColBin::e>(binX);
00114 rowBin = static_cast<RowBin::e>(binY);
00115 } else {
00116 colBin = ColBin::none;
00117 rowBin = RowBin::none;
00118 }
00119
00120 roiCentered = false;
00121 roiStartX = minRegion.x;
00122 roiStartY = minRegion.y;
00123 }
00124
00125 void Shot::roiRegionLarger(const Size &minSize, bool useBinning) {
00126 FCam::Rect region(0,0, minSize.width, minSize.height);
00127 roiRegionLarger(region, useBinning);
00128 }
00129
00130 }}