Skip to content
Snippets Groups Projects
Commit 2cec3a8f authored by even's avatar even
Browse files

Scanner area storage

parent eaaf8d66
No related branches found
No related tags found
No related merge requests found
......@@ -57,6 +57,7 @@ void BSIdetItem::setImage (QImage *image, VMap *idata)
this->gMap = idata;
this->imageWidth = image->width ();
this->imageHeight = image->height ();
scanp.setSize (image->width (), image->height ());
}
......@@ -75,7 +76,7 @@ void BSIdetItem::buildScans (Pt2i p1, Pt2i p2)
offy = 0;
// Gets a scan iterator
ds = scanp.getScanner (p1, p2, 0, 0, imageWidth, imageHeight);
ds = scanp.getScanner (p1, p2);
// Extracts the left scan (with central one)
vector<Pt2i> pix;
......
......@@ -108,6 +108,7 @@ void BSProfileItem::setImage (QImage *image, VMap *idata)
this->gMap = idata;
this->imageWidth = image->width ();
this->imageHeight = image->height ();
scanp.setSize (image->width (), image->height ());
}
......@@ -127,8 +128,7 @@ void BSProfileItem::buildScans (Pt2i p1, Pt2i p2)
stripe = 0;
// Gets a scan iterator
DirectionalScanner *ds = scanp.getScanner (p1, p2,
0, 0, imageWidth, imageHeight);
DirectionalScanner *ds = scanp.getScanner (p1, p2);
// Extracts the left scan (with central one)
vector<Pt2i> pix;
......
......@@ -70,6 +70,7 @@ void BSTracker::clear ()
void BSTracker::setGradientMap (VMap *data)
{
gMap = data;
scanp.setSize (gMap->getWidth (), gMap->getHeight ());
delete cand;
cand = new int[data->getHeightWidthMax ()];
}
......@@ -81,10 +82,8 @@ BlurredSegment *BSTracker::fastTrack (const Pt2i &p1, const Pt2i &p2,
// Creates the scanner
DirectionalScanner *ds = NULL;
if (p0 != NULL)
ds = scanp.getScanner (*p0, p1.vectorTo (p2), 4 * imaxWidth, false,
0, 0, gMap->getWidth (), gMap->getHeight ());
else ds = scanp.getScanner (p1, p2,
0, 0, gMap->getWidth (), gMap->getHeight ());
ds = scanp.getScanner (*p0, p1.vectorTo (p2), 4 * imaxWidth, false);
else ds = scanp.getScanner (p1, p2);
if (ds == NULL) return NULL;
// Builds a BS builder around a central point
......@@ -210,9 +209,8 @@ BlurredSegment *BSTracker::fineTrack (const Pt2i &center, const Vr2i &scandir,
fail = 0;
// Creation of the directional scanner and the array of candidates
DirectionalScanner *ds = scanp.getScanner (
center, normal, scanwidth, dynamicScans,
0, 0, gMap->getWidth (), gMap->getHeight ());
DirectionalScanner *ds = scanp.getScanner (center, normal,
scanwidth, dynamicScans);
if (ds == NULL)
{
fail = FAILURE_NO_START;
......
......@@ -256,6 +256,15 @@ private :
static const int FAILURE_LOST_ORIENTATION;
/** Scanned map left bound. */
int xmin;
/** Scanned map lower bound. */
int ymin;
/** Scanned map width. */
int width;
/** Scanned map height. */
int height;
/** Blurred segment max width for fast tracks. */
int imaxWidth;
/** Blurred segment max width for fine tracks. */
......
#include <cstdlib>
#include <iostream>
// #include <cstdlib>
// #include <iostream>
#include "scannerprovider.h"
#include "directionalscannero2.h"
#include "directionalscannero7.h"
......@@ -12,9 +12,7 @@
DirectionalScanner *ScannerProvider::getScanner (
Pt2i p1, Pt2i p2,
int xmin, int ymin, int xmax, int ymax)
DirectionalScanner *ScannerProvider::getScanner (Pt2i p1, Pt2i p2)
{
// Enforces P1 to be lower than P2
// or to left of P2 in cas of equality
......@@ -99,9 +97,8 @@ DirectionalScanner *ScannerProvider::getScanner (
DirectionalScanner *ScannerProvider::getScanner (
Pt2i p1, Pt2i p2, Pt2i v1, Pt2i v2,
int xmin, int ymin, int xmax, int ymax)
DirectionalScanner *ScannerProvider::getScanner (Pt2i p1, Pt2i p2,
Pt2i v1, Pt2i v2)
{
// Get the scan strip center
int cx = (p1.x () + p2.x ()) / 2;
......@@ -138,13 +135,12 @@ DirectionalScanner *ScannerProvider::getScanner (
a, b, c1, c2, nbs, steps, cx, cy));
else
return (new DirectionalScannerO7 (xmin, ymin, xmax, ymax,
a, b, c1, c2, nbs, steps, cx, cy));
a, b, c1, c2, nbs, steps, cx, cy));
}
DirectionalScanner *ScannerProvider::getScanner (
Pt2i centre, Vr2i normal, int length,
int xmin, int ymin, int xmax, int ymax)
DirectionalScanner *ScannerProvider::getScanner (Pt2i centre, Vr2i normal,
int length)
{
// Gets the steps position array
int nbs = 0;
......@@ -181,9 +177,8 @@ DirectionalScanner *ScannerProvider::getScanner (
}
DirectionalScanner *ScannerProvider::getScanner (
Pt2i centre, Vr2i normal, int length, bool controlable,
int xmin, int ymin, int xmax, int ymax)
DirectionalScanner *ScannerProvider::getScanner (Pt2i centre, Vr2i normal,
int length, bool controlable)
{
// Gets the steps position array
int nbs = 0;
......
......@@ -13,7 +13,6 @@ using namespace std;
* \brief Directional scanner provider.
* Provides ad-hoc directional scanners in the relevant octant
* and according to static or dynamical needs.
* \author {P. Even}
*/
class ScannerProvider
{
......@@ -24,28 +23,42 @@ public:
* @fn ScannerProvider()
* \brief Builds a directional scanner provider.
*/
ScannerProvider () : isOrtho (false) { }
ScannerProvider () : isOrtho (false),
xmin (0), ymin (0), xmax (100), ymax (100) { }
/**
* @fn getScanner(Pt2i p1, Pt2i p2,
* int xmin, int xmax, int ymin, int ymax)
* @fn void setSize (int sizex, int sizey)
* \brief Sets the scanned area size.
* @param sizex Scan area width.
* @param sizey Scan area height.
*/
void setSize (int sizex, int sizey) {
xmax = xmin + sizex; ymax = ymin + sizey; }
/**
* @fn void setArea (int x0, int y0, int sizex, in sizey)
* \brief Sets the scanned area size.
* @param x0 Left column coordinate of the scan area.
* @param y0 Lower line coordinate of the scan area.
* @param sizex Scan area width.
* @param sizey Scan area height.
*/
void setArea (int x0, int y0, int sizex, int sizey) {
xmin = x0, ymin = y0, xmax = x0 + sizex; ymax = y0 + sizey; }
/**
* @fn getScanner(Pt2i p1, Pt2i p2)
* \brief Returns an incremental directional scanner.
* Returns a directional scanner from two control points.
* The scan strip is composed of parallel scan lines, the first one being
* defined by control points p1 and p2.
* @param p1 Start control point.
* @param p2 End control point.
* @param xmin Left border of the scan area.
* @param xmax Right border of the scan area.
* @param ymin Low border of the scan area.
* @param ymax Up border of the scan area.
*/
DirectionalScanner *getScanner (Pt2i p1, Pt2i p2,
int xmin, int xmax, int ymin, int ymax);
DirectionalScanner *getScanner (Pt2i p1, Pt2i p2);
/**
* @fn getScanner(Pt2i p1, Pt2i p2, Pt2i v1, Pt2i v2,
* int xmin, int ymin, nt xmax, int ymax)
* @fn getScanner(Pt2i p1, Pt2i p2, Pt2i v1, Pt2i v2)
* \brief Returns an incremental directional scanner.
* Returns a directional scanner from two points and direction v1 -> v2.
* The scan strip is composed of parallel scan lines, centered on the middle
......@@ -54,18 +67,11 @@ public:
* @param p2 end control point
* @param v1 direction start point
* @param v2 direction end point
* @param xmin left border of the scan area
* @param xmax right border of the scan area
* @param ymin low border of the scan area
* @param ymax up border of the scan area
*/
DirectionalScanner *getScanner (Pt2i p1, Pt2i p2,
Pt2i v1, Pt2i v2,
int xmin, int ymin, int xmax, int ymax);
DirectionalScanner *getScanner (Pt2i p1, Pt2i p2, Pt2i v1, Pt2i v2);
/**
* @fn getScanner(Pt2i centre, Vr2i normal, int length,
* int xmin, int ymin, nt xmax, int ymax)
* @fn getScanner(Pt2i centre, Vr2i normal, int length)
* \brief Returns an incremental directional scanner.
* Returns a directional scanner from two points and direction v1 -> v2.
* The scan strip is composed of parallel scan lines, centered on the middle
......@@ -73,13 +79,8 @@ public:
* @param centre central point
* @param normal scan strip normal vector
* @param length length of a scan line
* @param xmin left border of the scan area
* @param xmax right border of the scan area
* @param ymin low border of the scan area
* @param ymax up border of the scan area
*/
DirectionalScanner *getScanner (Pt2i centre, Vr2i normal, int length,
int xmin, int ymin, int xmax, int ymax);
DirectionalScanner *getScanner (Pt2i centre, Vr2i normal, int length);
/**
* @fn getScanner(Pt2i centre, Vr2i normal, int length, bool controlable,
......@@ -92,14 +93,9 @@ public:
* @param normal scan strip normal vector
* @param length length of a scan line
* @param controlable controlability request (true for a dynamical scanner)
* @param xmin left border of the scan area
* @param xmax right border of the scan area
* @param ymin low border of the scan area
* @param ymax up border of the scan area
*/
DirectionalScanner *getScanner (Pt2i centre, Vr2i normal,
int length, bool controlable,
int xmin, int ymin, int xmax, int ymax);
int length, bool controlable);
/**
* @fn setOrtho(bool status)
......@@ -113,6 +109,15 @@ private:
/** Orthogonal scanner modality. */
bool isOrtho;
/** Scan area lowest x coordinate. */
int xmin;
/** Scan area lowest y coordinate. */
int ymin;
/** Scan area highest x coordinate. */
int xmax;
/** Scan area highest y coordinate. */
int ymax;
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment