Commits (8)
#-------------------------------------------------------------------------------
# Copyright (c) 2013, Lars Baehren <lbaehren@gmail.com>
# All rights reserved.
......@@ -104,7 +103,7 @@ if (NOT NUMPY_FOUND)
##__________________________________________________________________________
## Actions taken when all components have been found
find_package_handle_standard_args (NUMPY DEFAULT_MSG NUMPY_INCLUDE_DIRS)
find_package_handle_standard_args (NumPy DEFAULT_MSG NUMPY_INCLUDE_DIRS)
if (NUMPY_FOUND)
if (NOT NUMPY_FIND_QUIETLY)
......
......@@ -61,7 +61,14 @@ extern "C"
#if PY_VERSION_HEX >= 0x03000000
int @PROJECT_NAME_LOWER@_import_array()
{
import_array();
//#define import_array1(ret) {
// if (_import_array() < 0) {
// PyErr_Print();
// PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import");
// return ret;
// }
//}
import_array1(-1);
return 0;
}
#else
......
......@@ -195,7 +195,7 @@ void SinkTaskMgr<Result>::getHistory(std::list<Result> & anHistory,int fromFrame
int current_index = _currentFrameNumber % _historyResult.size();
int from_index = fromFrameNumber % _historyResult.size();
if(_currentFrameNumber - fromFrameNumber >= _historyResult.size()) // return all history
if(_currentFrameNumber - fromFrameNumber >= int(_historyResult.size())) // return all history
{
from_index = 0;
current_index = int(_historyResult.size()) - 1;
......
......@@ -152,13 +152,13 @@ static void _max_intensity(const Data &aSrc,
const Buffer &projection_x,const Buffer & projection_y,
BpmResult &aResult)
{
Buffer *aBufferPt = aSrc.buffer;
INPUT *aSrcPt = (INPUT*)aBufferPt->data;
int yMaxPos = _max_intensity_position<SUMMTYPE>(projection_y,aSrc.dimensions[1]);
int xMaxPos = _max_intensity_position<SUMMTYPE>(projection_x,aSrc.dimensions[0]);
bool xPositionFound = xMaxPos > 0 && xMaxPos < (aSrc.dimensions[0] - 1);
bool yPositionFound = yMaxPos > 0 && yMaxPos < (aSrc.dimensions[1] - 1);
const int& width = aSrc.dimensions[0];
const int& height = aSrc.dimensions[1];
int yMaxPos = _max_intensity_position<SUMMTYPE>(projection_y,height);
int xMaxPos = _max_intensity_position<SUMMTYPE>(projection_x,width);
bool xPositionFound = xMaxPos > 0 && xMaxPos < (width - 1);
bool yPositionFound = yMaxPos > 0 && yMaxPos < (height - 1);
if(xPositionFound)
{
aResult.max_pixel_x = xMaxPos;
......@@ -169,25 +169,25 @@ static void _max_intensity(const Data &aSrc,
aResult.max_pixel_y = yMaxPos;
aResult.beam_center_y = (double)yMaxPos;
}
// get the five pixel values around x_max_pos and y_max_pos
if(xPositionFound && yPositionFound)
{
// Center left Pixel
aSrcPt += yMaxPos * aSrc.dimensions[0] + xMaxPos - 1;
Buffer *aBufferPt = aSrc.buffer;
INPUT *aSrcPt = (INPUT*)aBufferPt->data;
// Center Pixel
aSrcPt += yMaxPos * width + xMaxPos;
// keep the intensity of the center pixel as the maximum value
aResult.max_pixel_value = (unsigned int)*aSrcPt;
// average the five pixels around x_max_pos and y_max_pos
unsigned long long aBeamSum = *aSrcPt;
aResult.max_pixel_value = (unsigned int)aBeamSum;
// Center Pixel
++aSrcPt;
aBeamSum += *aSrcPt;
// Center left Pixel
aBeamSum += *(aSrcPt - 1);
// Center right Pixel
++aSrcPt;
aBeamSum += *aSrcPt;
aBeamSum += *(aSrcPt + 1);
// Top Pixel
aSrcPt -= aSrc.dimensions[0] + 1;
aBeamSum += *aSrcPt;
aBeamSum += *(aSrcPt - width);
// Bottom Pixel
aSrcPt += aSrc.dimensions[0] << 1;
aBeamSum += *aSrcPt;
aBeamSum += *(aSrcPt + width);
aResult.beam_intensity = (double)(aBeamSum) / 5.;
}
else
......