本文整理汇总了C++中boost::circular_buffer::end方法的典型用法代码示例。如果您正苦于以下问题:C++ circular_buffer::end方法的具体用法?C++ circular_buffer::end怎么用?C++ circular_buffer::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::circular_buffer
的用法示例。
在下文中一共展示了circular_buffer::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawMatchedIdPatternHistogram
void GestureClassifierByHistogram::drawMatchedIdPatternHistogram(const boost::circular_buffer<size_t> &matchedHistogramIndexes, const std::string &windowName) const
{
// calculate matched index histogram
cv::MatND hist;
#if defined(__GNUC__)
{
cv::Mat tmpmat(std::vector<unsigned char>(matchedHistogramIndexes.begin(), matchedHistogramIndexes.end()));
cv::calcHist(&tmpmat, 1, local::indexHistChannels, cv::Mat(), hist, local::histDims, local::indexHistSize, local::indexHistRanges, true, false);
}
#else
cv::calcHist(&cv::Mat(std::vector<unsigned char>(matchedHistogramIndexes.begin(), matchedHistogramIndexes.end())), 1, local::indexHistChannels, cv::Mat(), hist, local::histDims, local::indexHistSize, local::indexHistRanges, true, false);
#endif
// normalize histogram
//HistogramUtil::normalizeHistogram(hist, params_.maxMatchedHistogramNum);
// draw matched index histogram
cv::Mat histImg(cv::Mat::zeros(local::indexHistMaxHeight, local::indexHistBins*local::indexHistBinWidth, CV_8UC3));
HistogramUtil::drawHistogram1D(hist, local::indexHistBins, params_.maxMatchedHistogramNum, local::indexHistBinWidth, local::indexHistMaxHeight, histImg);
std::ostringstream sstream;
sstream << "count: " << matchedHistogramIndexes.size();
cv::putText(histImg, sstream.str(), cv::Point(10, 15), cv::FONT_HERSHEY_COMPLEX, 0.5, CV_RGB(255, 0, 255), 1, 8, false);
cv::imshow(windowName, histImg);
}
示例2: image_obj_callback
void image_obj_callback(const autoware_msgs::image_obj::ConstPtr& image_obj_msg) {
pthread_mutex_lock(&mutex);
image_obj_ringbuf.push_front(*image_obj_msg);
//vscan_image is empty
if (vscan_image_ringbuf.begin() == vscan_image_ringbuf.end()) {
pthread_mutex_unlock(&mutex);
ROS_INFO("vscan_image ring buffer is empty");
return;
}
buf_flag = true;
// image_obj > vscan_image
if (get_time(&(image_obj_ringbuf.front().header)) >= get_time(&(vscan_image_ringbuf.front().header))) {
vscan_image_buf = vscan_image_ringbuf.front();
boost::circular_buffer<autoware_msgs::image_obj>::iterator it = image_obj_ringbuf.begin();
if (image_obj_ringbuf.size() == 1) {
image_obj_buf = *it;
pthread_mutex_unlock(&mutex);
return;
} else {
for (it++; it != image_obj_ringbuf.end(); it++) {
if (fabs_time_diff(&(vscan_image_ringbuf.front().header), &((it-1)->header))
< fabs_time_diff(&(vscan_image_ringbuf.front().header), &(it->header))) {
image_obj_buf = *(it-1);
break;
}
}
if (it == image_obj_ringbuf.end()) {
image_obj_buf = image_obj_ringbuf.back();
}
}
} else {
image_obj_buf = image_obj_ringbuf.front();
boost::circular_buffer<autoware_msgs::PointsImage>::iterator it = vscan_image_ringbuf.begin();
if (vscan_image_ringbuf.size() == 1) {
vscan_image_buf = *it;
pthread_mutex_unlock(&mutex);
return;
}
for (it++; it != vscan_image_ringbuf.end(); it++) {
if (fabs_time_diff(&(image_obj_ringbuf.front().header), &((it-1)->header))
< fabs_time_diff(&(image_obj_ringbuf.front().header), &(it->header))) {
vscan_image_buf = *(it-1);
break;
}
}
if (it == vscan_image_ringbuf.end()) {
vscan_image_buf = vscan_image_ringbuf.back();
}
}
pthread_mutex_unlock(&mutex);
}
示例3: image_obj_ranged_callback
void image_obj_ranged_callback(const cv_tracker::image_obj_ranged::ConstPtr& image_obj_ranged_msg) {
pthread_mutex_lock(&mutex);
image_obj_ranged_ringbuf.push_front(*image_obj_ranged_msg);
//image_raw is empty
if (image_raw_ringbuf.begin() == image_raw_ringbuf.end()) {
pthread_mutex_unlock(&mutex);
ROS_INFO("image_raw ring buffer is empty");
return;
}
buf_flag = true;
// image_obj_ranged > image_raw
if (get_time(&(image_obj_ranged_ringbuf.front().header)) >= get_time(&(image_raw_ringbuf.front().header))) {
image_raw_buf = image_raw_ringbuf.front();
boost::circular_buffer<cv_tracker::image_obj_ranged>::iterator it = image_obj_ranged_ringbuf.begin();
if (image_obj_ranged_ringbuf.size() == 1) {
image_obj_ranged_buf = *it;
pthread_mutex_unlock(&mutex);
return;
} else {
for (it++; it != image_obj_ranged_ringbuf.end(); it++) {
if (fabs_time_diff(&(image_raw_ringbuf.front().header), &((it-1)->header))
< fabs_time_diff(&(image_raw_ringbuf.front().header), &(it->header))) {
image_obj_ranged_buf = *(it-1);
break;
}
}
if (it == image_obj_ranged_ringbuf.end()) {
image_obj_ranged_buf = image_obj_ranged_ringbuf.back();
}
}
} else {
image_obj_ranged_buf = image_obj_ranged_ringbuf.front();
boost::circular_buffer<sensor_msgs::Image>::iterator it = image_raw_ringbuf.begin();
if (image_raw_ringbuf.size() == 1) {
image_raw_buf = *it;
pthread_mutex_unlock(&mutex);
return;
}
for (it++; it != image_raw_ringbuf.end(); it++) {
if (fabs_time_diff(&(image_obj_ranged_ringbuf.front().header), &((it-1)->header))
< fabs_time_diff(&(image_obj_ranged_ringbuf.front().header), &(it->header))) {
image_raw_buf = *(it-1);
break;
}
}
if (it == image_raw_ringbuf.end()) {
image_raw_buf = image_raw_ringbuf.back();
}
}
pthread_mutex_unlock(&mutex);
}
示例4: dumpLegendrePolynomialCacheData
//! Dump Legendre polynomial cache data to stream (table and history).
void dumpLegendrePolynomialCacheData( std::ostream& outputStream,
boost::unordered_map< Point, double > cacheTable,
boost::circular_buffer< Point > cacheHistory )
{
outputStream << "Table:\n";
for ( boost::unordered_map< Point, double >::iterator iteratorCacheTable = cacheTable.begin( );
iteratorCacheTable != cacheTable.end( ); iteratorCacheTable++ )
{
outputStream << "\t" << writeLegendrePolynomialStructureToString(
iteratorCacheTable->first ).c_str( ) << " => "
<< iteratorCacheTable->second << std::endl;
}
outputStream << "History:\n";
for ( boost::circular_buffer< Point >::iterator iteratorCacheHistory = cacheHistory.begin( );
iteratorCacheHistory != cacheHistory.end( ); iteratorCacheHistory++ )
{
outputStream << "\t"
<< writeLegendrePolynomialStructureToString( *iteratorCacheHistory ).c_str( )
<< ", ";
}
outputStream << std::endl;
}
示例5: write
/** Try to write a value to the pipe
\param[in] value is what we want to write
\param[in] blocking specify if the call wait for the operation
to succeed
\return true on success
\todo provide a && version
*/
bool write(const T &value, bool blocking = false) {
// Lock the pipe to avoid being disturbed
std::unique_lock<std::mutex> ul { cb_mutex };
TRISYCL_DUMP_T("Write pipe full = " << full()
<< " value = " << value);
if (blocking)
/* If in blocking mode, wait for the not full condition, that
may be changed when a read is done */
read_done.wait(ul, [&] { return !full(); });
else if (full())
return false;
cb.push_back(value);
TRISYCL_DUMP_T("Write pipe front = " << cb.front()
<< " back = " << cb.back()
<< " cb.begin() = " << (void *)&*cb.begin()
<< " cb.size() = " << cb.size()
<< " cb.end() = " << (void *)&*cb.end()
<< " reserved_for_reading() = " << reserved_for_reading()
<< " reserved_for_writing() = " << reserved_for_writing());
// Notify the clients waiting to read something from the pipe
write_done.notify_all();
return true;
}
示例6: matchHistogramByGestureIdPattern
size_t GestureClassifierByHistogram::matchHistogramByGestureIdPattern(const boost::circular_buffer<size_t> &matchedHistogramIndexes, const std::vector<histogram_type> &gestureIdPatternHistograms, const double histDistThreshold) const
{
// create matched ID histogram
#if 0
cv::MatND hist;
cv::calcHist(
&cv::Mat(std::vector<unsigned char>(matchedHistogramIndexes.begin(), matchedHistogramIndexes.end())),
1, phaseHistChannels, cv::Mat(), hist, histDims, phaseHistSize, phaseHistRanges, true, false
);
#else
cv::MatND hist = cv::MatND::zeros(local::gesturePatternHistogramBinNum, 1, CV_32F);
float *binPtr = (float *)hist.data;
for (boost::circular_buffer<size_t>::const_iterator it = matchedHistogramIndexes.begin(); it != matchedHistogramIndexes.end(); ++it)
if (*it != (size_t)-1) ++(binPtr[*it]);
#endif
// match histogram
double minHistDist = std::numeric_limits<double>::max();
const size_t &matchedIdx = gestureIdPatternHistograms.empty() ? -1 : HistogramMatcher::match(gestureIdPatternHistograms, hist, minHistDist);
// FIXME [delete] >>
//std::cout << "\t\t\t*** " << minHistDist << std::endl;
return minHistDist < histDistThreshold ? matchedIdx : -1;
}
示例7: reserved_for_writing
/** Compute the amount of elements blocked by write reservations, not yet
committed
This includes some normal writes to pipes between/after
un-committed reservations
This function assumes that the data structure is locked
*/
std::size_t reserved_for_writing() const {
if (w_rid_q.empty())
// No on-going reservation
return 0;
else
/* The reserved size is from the first element of the first
on-going reservation up to the end of the pipe content */
return cb.end() - w_rid_q.front().start;
}
示例8: size
/** Get the current number of elements in the pipe that can be read
This is obviously a volatile value which is constrained by the
theory of restricted relativity.
Note that on some devices it may be costly to implement (for
example on FPGA).
*/
std::size_t size() const {
TRISYCL_DUMP_T("size() cb.size() = " << cb.size()
<< " cb.end() = " << (void *)&*cb.end()
<< " reserved_for_reading() = " << reserved_for_reading()
<< " reserved_for_writing() = " << reserved_for_writing());
/* The actual number of available elements depends from the
elements blocked by some reservations.
This prevents a consumer to read into reserved area. */
return cb.size() - reserved_for_reading() - reserved_for_writing();
}
示例9: circ_buff_median
// Helper function: compute the median of a circular buffer
double circ_buff_median(const boost::circular_buffer<double>& cb) const {
// FIXME: naive implementation; creates a copy as a vector
std::vector<double> v;
for (boost::circular_buffer<double>::const_iterator i = cb.begin();
i != cb.end(); ++i) {
v.push_back(*i);
}
size_t n = v.size() / 2;
std::nth_element(v.begin(), v.begin()+n, v.end());
return v[n];
}
示例10: find
ros::Time find(ros::Time sensor_time) {
boost::circular_buffer<ros::Time>::iterator it = sensor.begin();
for (int i = 0; it != sensor.end(); it++, i++) {
if (it->sec == sensor_time.sec && it->nsec == sensor_time.nsec) {
return execution.at(i); // find
}
}
ROS_ERROR("error:not found a pair");
ros::Time failed;
failed.sec = 0;
failed.nsec = 0;
return failed; // not find
}
示例11: SaveEntry
void CSearchDialog::SaveEntry(int comboBoxId, boost::circular_buffer<std::wstring> &buffer)
{
TCHAR entry[MAX_PATH];
GetDlgItemText(m_hDlg, comboBoxId, entry, SIZEOF_ARRAY(entry));
std::wstring strEntry(entry);
auto itr = std::find_if(buffer.begin(), buffer.end(),
[strEntry] (const std::wstring Pattern)
{
return Pattern.compare(strEntry) == 0;
});
HWND hComboBox = GetDlgItem(m_hDlg, comboBoxId);
ComboBox_SetCurSel(hComboBox, -1);
if(itr != buffer.end())
{
/* Remove the current element from both the list and the
combo box. It will be reinserted at the front of both below. */
auto index = std::distance(buffer.begin(), itr);
SendMessage(hComboBox, CB_DELETESTRING, index, 0);
buffer.erase(itr);
}
buffer.push_front(entry);
SendMessage(hComboBox, CB_INSERTSTRING, 0, reinterpret_cast<LPARAM>(entry));
ComboBox_SetCurSel(hComboBox, 0);
ComboBox_SetEditSel(hComboBox, -1, -1);
if(ComboBox_GetCount(hComboBox) > buffer.capacity())
{
SendMessage(hComboBox, CB_DELETESTRING, ComboBox_GetCount(hComboBox) - 1, 0);
}
}
示例12: vscan_image_callback
void vscan_image_callback(const autoware_msgs::PointsImage::ConstPtr& vscan_image_msg) {
pthread_mutex_lock(&mutex);
vscan_image_ringbuf.push_front(*vscan_image_msg);
//image_obj is empty
if (image_obj_ringbuf.begin() == image_obj_ringbuf.end()) {
ROS_INFO("image_obj ring buffer is empty");
buf_flag = false;
pthread_mutex_unlock(&mutex);
return;
}
buf_flag = true;
pthread_mutex_unlock(&mutex);
if (image_obj_ranged_flag == true) {
publish();
}
}
示例13: BinData
void CTimeSmoother::BinData(const boost::circular_buffer<double> &data, vector<double> &bins, const double threshold, const unsigned int minbinsize)
{
if (!data.size())
return;
bins.clear();
vector<unsigned int> counts;
for (boost::circular_buffer<double>::const_iterator i = data.begin(); i != data.end(); ++i)
{
bool found = false;
for (unsigned int j = 0; j < bins.size(); ++j)
{
if (fabs(*i - bins[j]) < threshold*bins[j])
{
found = true;
// update our bin mean and count
bins[j] = (bins[j]*counts[j] + *i)/(counts[j]+1);
counts[j]++;
break;
}
}
if (!found)
{
bins.push_back(*i);
counts.push_back(1);
}
}
if (minbinsize)
{
assert(counts.size() == bins.size());
assert(counts.size());
// filter out any bins that are not large enough (and any bins that aren't positive)
for (unsigned int j = 0; j < counts.size(); )
{
if (counts[j] < minbinsize || bins[j] < 0.05)
{
bins.erase(bins.begin() + j);
counts.erase(counts.begin() + j);
}
else
j++;
}
}
}
示例14: image_raw_callback
void image_raw_callback(const sensor_msgs::Image::ConstPtr& image_raw_msg) {
pthread_mutex_lock(&mutex);
image_raw_ringbuf.push_front(*image_raw_msg);
//image_obj_ranged is empty
if (image_obj_ranged_ringbuf.begin() == image_obj_ranged_ringbuf.end()) {
ROS_INFO("image_obj_ranged ring buffer is empty");
buf_flag = false;
pthread_mutex_unlock(&mutex);
return;
}
buf_flag = true;
pthread_mutex_unlock(&mutex);
pthread_mutex_lock(&mutex);
if (image_obj_tracked_flag == true) {
publish();
}
pthread_mutex_unlock(&mutex);
}
示例15: GetIntRepresentation
void CTimeSmoother::GetIntRepresentation(const boost::circular_buffer<double> &data, vector<unsigned int> &intData, const vector<double> &bins, const vector<unsigned int> &intBins)
{
intData.clear();
for (boost::circular_buffer<double>::const_iterator i = data.begin(); i != data.end(); ++i)
{
double min_r2 = numeric_limits<double>::max();
unsigned int min_j = 0;
for (unsigned int j = 0; j < bins.size(); ++j)
{
double d = MathUtils::round_int(*i/bins[j]);
double r2 = (*i - bins[j]*d)*(*i - bins[j]*d);
if (r2 < min_r2)
{
min_j = j;
min_r2 = r2;
}
}
intData.push_back(MathUtils::round_int(*i/bins[min_j])*intBins[min_j]);
}
}