/** * Read the accumulated value. * * Read the value that has been accumulating. * The accumulator is attached after the oversample and average engine. * * @return The 64-bit value accumulated since the last Reset(). */ int64_t AnalogInput::GetAccumulatorValue() const { if (StatusIsFatal()) return 0; int32_t status = 0; int64_t value = getAccumulatorValue(m_port, &status); wpi_setErrorWithContext(status, getHALErrorMessage(status)); return value + m_accumulatorOffset; }
/* * Class: edu_wpi_first_wpilibj_hal_AnalogJNI * Method: getAccumulatorValue * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)J */ JNIEXPORT jlong JNICALL Java_edu_wpi_first_wpilibj_hal_AnalogJNI_getAccumulatorValue (JNIEnv * env, jclass, jobject id, jobject status) { void ** javaId = (void**)env->GetDirectBufferAddress(id); ANALOGJNI_LOG(logDEBUG) << "Analog Ptr = " << *javaId; jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); jlong returnValue = getAccumulatorValue(*javaId, statusPtr); ANALOGJNI_LOG(logDEBUG) << "Status = " << *statusPtr; ANALOGJNI_LOG(logDEBUG) << "AccumulatorValue = " << returnValue; return returnValue; }
void THIS::getImage( puma2::ColorImageRGB8& target ) { /* large bins: x and y-position small bins: y -> orientation, x -> scale pixel grey value: number of entries in bin depending on maximum value */ float norm = 255.0 / getMaxAccumulatorValue(); int w = (m_ScaleBins+1)*m_XLocationBins; int h = (m_OrientationBins+1)*m_YLocationBins; target.resize( w, h ); for ( int y=0; y<h; y++ ) { for ( int x=0; x<w; x++ ) { int scaleIndex = x % (m_ScaleBins+1); int orientationIndex = y % (m_OrientationBins+1); if ( ( scaleIndex >= m_ScaleBins ) || ( orientationIndex >= m_OrientationBins ) ) { target[y][x][0] = 0; target[y][x][1] = 0; target[y][x][2] = 255; continue; } int xIndex = x / (m_ScaleBins+1); int yIndex = y / (m_OrientationBins+1); unsigned int histValue; getAccumulatorValue(scaleIndex, orientationIndex, xIndex, yIndex, histValue); if ( histValue == 0 ) { target[y][x][0] = 0; target[y][x][1] = 0; target[y][x][2] = 0; } else { target[y][x][0] = histValue * norm; target[y][x][1] = histValue * norm; target[y][x][2] = histValue * norm; } } } }
void THIS::getImage( cv::Mat& target ) { /* large bins: x and y-position small bins: y -> orientation, x -> scale pixel grey value: number of entries in bin depending on maximum value */ float norm = 255.0 / getMaxAccumulatorValue(); int w = (m_ScaleBins+1)*m_XLocationBins; int h = (m_OrientationBins+1)*m_YLocationBins; target.create( h, w, CV_8UC3 ); for ( int y=0; y<h; y++ ) { for ( int x=0; x<w; x++ ) { int scaleIndex = x % (m_ScaleBins+1); int orientationIndex = y % (m_OrientationBins+1); if ( ( scaleIndex >= m_ScaleBins ) || ( orientationIndex >= m_OrientationBins ) ) { target.at<cv::Vec3b>(y,x) = cv::Vec3b(0,0,255); continue; } int xIndex = x / (m_ScaleBins+1); int yIndex = y / (m_OrientationBins+1); unsigned int histValue; getAccumulatorValue(scaleIndex, orientationIndex, xIndex, yIndex, histValue); if ( histValue == 0 ) { target.at<cv::Vec3b>(y,x) = cv::Vec3b(0,0,0); } else { target.at<cv::Vec3b>(y,x) = cv::Vec3b(histValue * norm,histValue * norm,histValue * norm); } } } }