static gboolean hook_increment(gpointer k, gpointer v, gpointer u) { (void) k; (void) u; OV(v)->version ++; OV(v)->when = time(0); return FALSE; }
static gboolean hook_increment(gpointer k, gpointer v, gpointer u) { (void) k; (void) u; OV(v)->version ++; OV(v)->when = oio_ext_real_time() / G_TIME_SPAN_SECOND; return FALSE; }
static gboolean hook_dump(gpointer k, gpointer v, gpointer u) { GString *gstr = u; if (hashstr_len(k) <= 0 || !*hashstr_str(k)) return FALSE; if (gstr->len > 0) g_string_append_c(gstr, ','); g_string_append_printf(gstr, "(%.*s,%"G_GINT64_FORMAT",%"G_GINT64_FORMAT")", (int)hashstr_len(k), hashstr_str(k), OV(v)->version, OV(v)->when); return FALSE; }
void ViewCameraGL::save(const QString& filename) const { QFile file(filename); if(file.open( QIODevice::WriteOnly )) { file.flush(); QTextStream stream ( &file ); stream << __azimuth << " " << __elevation; stream << " " << __stepMove; OV(stream,__center); OV(stream,__eye); OV(stream,__translation); stream << " " << __radius << " " << __far_plane << " " << __near_plane; stream << " " << __default_view_angle << " " << __view_angle; stream << " " << __projectionmode << " " << __geomsys; } else QMessageBox::warning(__frame,tr("File Access"),tr("Cannot Open File")+" \""+filename+"\".",tr("Abort")); }
// ###################################################################### float DescriptorVec::getDominateOrientation(const Image<float> &img){ //get main orientation const int ORIENTARRAY = 36; Image<float> gradmag, gradori; gradientSobel(luminance(img), gradmag, gradori); //Add orientations to the histogram Histogram OV(ORIENTARRAY); for (int y=0; y<img.getHeight(); y++){ for(int x=0; x<img.getWidth(); x++){ const float gradVal = gradmag.getVal(x, y); float angle = gradori.getVal(x, y) + M_PI; angle = 0.5F * angle * ORIENTARRAY / M_PI; while (angle < 0.0F) angle += ORIENTARRAY; while (angle >= ORIENTARRAY) angle -= ORIENTARRAY; OV.addValueInterp(angle, 1 * gradVal); } } // smooth the orientation histogram 3 times: for (int i = 0; i < 3; i++) OV.smooth(); // find the max in the histogram: float maxPeakVal; int maxLoc; OV.findMax(maxLoc, maxPeakVal); // get value to the left of current value const float leftval = OV.getValue((maxLoc == 0) ? ORIENTARRAY-1 : maxLoc-1); // get value to the right of current value const float rightval = OV.getValue((maxLoc == ORIENTARRAY-1) ? 0 : maxLoc+1); // interpolate the values to get the orientation of the peak: // with f(x) = ax^2 + bx + c // f(-1) = x0 = leftval // f( 0) = x1 = midval // f(+1) = x2 = rightval // => a = (x0+x2)/2 - x1 // b = (x2-x0)/2 // c = x1 // f'(x) = 0 => x = -b/2a const float a = 0.5f * (leftval + rightval) - maxPeakVal; const float b = 0.5f * (rightval - leftval); float realangle = float(maxLoc) - 0.5F * b / a; realangle *= 2.0F * M_PI / ORIENTARRAY; // [0:36] to [0:2pi] realangle -= M_PI; // [0:2pi] to [-pi:pi] /* float realangle; // Find orientation peak: for (int bin = 0; bin < ORIENTARRAY; bin++) { // consider the peak centered around 'bin': const float midval = OV.getValue(bin); // if current value much smaller than global peak, forget it: if (midval < 0.8F * maxPeakValue) continue; // get value to the left of current value const float leftval = OV.getValue((bin == 0) ? ORIENTARRAY-1 : bin-1); // get value to the right of current value const float rightval = OV.getValue((bin == ORIENTARRAY-1) ? 0 : bin+1); // only consider local peaks: if (leftval >= midval) continue; if (rightval >= midval) continue; // interpolate the values to get the orientation of the peak: // with f(x) = ax^2 + bx + c // f(-1) = x0 = leftval // f( 0) = x1 = midval // f(+1) = x2 = rightval // => a = (x0+x2)/2 - x1 // b = (x2-x0)/2 // c = x1 // f'(x) = 0 => x = -b/2a const float a = 0.5f * (leftval + rightval) - midval; const float b = 0.5f * (rightval - leftval); realangle = float(bin) - 0.5F * b / a; realangle *= 2.0F * M_PI / ORIENTARRAY; // [0:36] to [0:2pi] realangle -= M_PI; // [0:2pi] to [-pi:pi] break; }*/ return realangle; }