… | |
… | |
118 | return; |
118 | return; |
119 | |
119 | |
120 | f->v2 /= f->n; |
120 | f->v2 /= f->n; |
121 | f->v3 /= f->n; |
121 | f->v3 /= f->n; |
122 | |
122 | |
123 | // this is a peculiar weightung, but it works fine |
|
|
124 | f->v1 /= 255.; |
123 | f->v1 /= 255.; |
125 | f->v2 /= 128. * 128.; |
124 | f->v2 /= 255. * 255.; f->v2 = sqrtf (f->v2); |
126 | f->v3 /= 128. * 128. * 64.; |
125 | f->v3 /= 255. * 255. * 255.; f->v3 = powf (fabsf (f->v3), 1./3.); |
127 | } |
126 | } |
128 | |
127 | |
129 | static guint32 a85_val; |
128 | static guint32 a85_val; |
130 | static guint a85_cnt; |
129 | static guint a85_cnt; |
131 | static guchar a85_buf[LINELENGTH], *a85_ptr; |
130 | static guchar a85_buf[LINELENGTH], *a85_ptr; |
… | |
… | |
244 | RETVAL = magic_file (cookie, path); |
243 | RETVAL = magic_file (cookie, path); |
245 | } |
244 | } |
246 | OUTPUT: |
245 | OUTPUT: |
247 | RETVAL |
246 | RETVAL |
248 | |
247 | |
249 | # missing in Gtk2 perl module |
248 | # missing/broken in Gtk2 perl module |
|
|
249 | |
|
|
250 | void |
|
|
251 | gdk_window_clear_hints (GdkWindow *window) |
|
|
252 | CODE: |
|
|
253 | gdk_window_set_geometry_hints (window, 0, 0); |
250 | |
254 | |
251 | gboolean |
255 | gboolean |
252 | gdk_net_wm_supports (GdkAtom property) |
256 | gdk_net_wm_supports (GdkAtom property) |
253 | CODE: |
257 | CODE: |
254 | #if defined(GDK_WINDOWING_X11) && !defined(GDK_MULTIHEAD_SAFE) |
258 | #if defined(GDK_WINDOWING_X11) && !defined(GDK_MULTIHEAD_SAFE) |
… | |
… | |
436 | |
440 | |
437 | ############################################################################# |
441 | ############################################################################# |
438 | |
442 | |
439 | MODULE = Gtk2::CV PACKAGE = Gtk2::CV::Schnauzer |
443 | MODULE = Gtk2::CV PACKAGE = Gtk2::CV::Schnauzer |
440 | |
444 | |
|
|
445 | # currently only works for filenames (octet strings) |
|
|
446 | |
441 | SV * |
447 | SV * |
442 | foldcase (SV *pathsv) |
448 | foldcase (SV *pathsv) |
443 | PROTOTYPE: $ |
449 | PROTOTYPE: $ |
444 | CODE: |
450 | CODE: |
445 | { |
451 | { |
446 | STRLEN plen; |
452 | STRLEN plen; |
447 | U8 *path = (U8 *)SvPVutf8 (pathsv, plen); |
453 | U8 *path = (U8 *)SvPV (pathsv, plen); |
448 | U8 *pend = path + plen; |
454 | U8 *pend = path + plen; |
449 | U8 dst [plen * 6 * 3], *dstp = dst; |
455 | U8 dst [plen * 6 * 3], *dstp = dst; |
450 | |
456 | |
451 | while (path < pend) |
457 | while (path < pend) |
452 | { |
458 | { |
453 | U8 ch = *path; |
459 | U8 ch = *path; |
454 | |
460 | |
455 | if (ch >= 'a' && ch <= 'z') |
461 | if (ch >= 'a' && ch <= 'z') |
456 | *dstp++ = *path++; |
462 | *dstp++ = *path++; |
|
|
463 | else if (ch >= 'A' && ch <= 'Z') |
|
|
464 | *dstp++ = *path++ + ('a' - 'A'); |
457 | else if (ch >= '0' && ch <= '9') |
465 | else if (ch >= '0' && ch <= '9') |
458 | { |
466 | { |
459 | STRLEN el, nl = 0; |
467 | STRLEN el, nl = 0; |
460 | while (*path >= '0' && *path <= '9' && path < pend) |
468 | while (*path >= '0' && *path <= '9' && path < pend) |
461 | path++, nl++; |
469 | path++, nl++; |
… | |
… | |
464 | *dstp++ = '0'; |
472 | *dstp++ = '0'; |
465 | |
473 | |
466 | memcpy (dstp, path - nl, nl); |
474 | memcpy (dstp, path - nl, nl); |
467 | dstp += nl; |
475 | dstp += nl; |
468 | } |
476 | } |
|
|
477 | else |
|
|
478 | *dstp++ = *path++; |
|
|
479 | #if 0 |
469 | else |
480 | else |
470 | { |
481 | { |
471 | STRLEN cl; |
482 | STRLEN cl; |
472 | to_utf8_fold (path, dstp, &cl); |
483 | to_utf8_fold (path, dstp, &cl); |
473 | dstp += cl; |
484 | dstp += cl; |
474 | path += is_utf8_char (path); |
485 | path += is_utf8_char (path); |
475 | } |
486 | } |
|
|
487 | #endif |
476 | } |
488 | } |
477 | |
489 | |
478 | RETVAL = newSVpvn ((const char *)dst, dstp - dst); |
490 | RETVAL = newSVpvn ((const char *)dst, dstp - dst); |
479 | } |
491 | } |
480 | OUTPUT: |
492 | OUTPUT: |
… | |
… | |
649 | { |
661 | { |
650 | int i; |
662 | int i; |
651 | AV *av, *result; |
663 | AV *av, *result; |
652 | |
664 | |
653 | if (!SvROK (ar) || SvTYPE (SvRV (ar)) != SVt_PVAV) |
665 | if (!SvROK (ar) || SvTYPE (SvRV (ar)) != SVt_PVAV) |
654 | croak ("Not an array ref as first argument to make_histogram"); |
666 | croak ("Not an array ref as first argument to extract_features"); |
655 | |
667 | |
656 | av = (AV *) SvRV (ar); |
668 | av = (AV *) SvRV (ar); |
657 | result = newAV (); |
669 | result = newAV (); |
658 | |
670 | |
659 | for (i = 0; i <= av_len (av); ++i) |
671 | for (i = 0; i <= av_len (av); ++i) |
… | |
… | |
712 | feature_finish_pass_2 (&f_v); |
724 | feature_finish_pass_2 (&f_v); |
713 | } |
725 | } |
714 | |
726 | |
715 | hist [0] = f_h.v1 * 2.; hist [1] = f_h.v2 * 2.; hist [2] = f_h.v3 * 2.; |
727 | hist [0] = f_h.v1 * 2.; hist [1] = f_h.v2 * 2.; hist [2] = f_h.v3 * 2.; |
716 | hist [3] = f_s.v1 ; hist [4] = f_s.v2 ; hist [5] = f_s.v3 ; |
728 | hist [3] = f_s.v1 ; hist [4] = f_s.v2 ; hist [5] = f_s.v3 ; |
717 | hist [6] = f_v.v1 ; hist [7] = f_v.v2 ; hist [8] = f_v.v3 ; |
729 | hist [6] = f_v.v1 * .5; hist [7] = f_v.v2 * .5; hist [8] = f_v.v3 * .5; |
718 | |
730 | |
719 | av_push (result, histsv); |
731 | av_push (result, histsv); |
720 | } |
732 | } |
721 | |
733 | |
722 | RETVAL = newRV_noinc ((SV *)result); |
734 | RETVAL = newRV_noinc ((SV *)result); |
723 | } |
735 | } |
724 | OUTPUT: |
736 | OUTPUT: |
725 | RETVAL |
737 | RETVAL |
726 | |
738 | |
727 | SV * |
|
|
728 | make_histograms (SV *ar) |
|
|
729 | CODE: |
|
|
730 | { |
|
|
731 | int i; |
|
|
732 | AV *av, *result; |
|
|
733 | |
|
|
734 | if (!SvROK (ar) || SvTYPE (SvRV (ar)) != SVt_PVAV) |
|
|
735 | croak ("Not an array ref as first argument to make_histogram"); |
|
|
736 | |
|
|
737 | av = (AV *) SvRV (ar); |
|
|
738 | result = newAV (); |
|
|
739 | |
|
|
740 | for (i = 0; i <= av_len (av); ++i) |
|
|
741 | { |
|
|
742 | const int HISTSIZE = 64; |
|
|
743 | |
|
|
744 | int j; |
|
|
745 | SV *sv = *av_fetch (av, i, 1); |
|
|
746 | STRLEN len; |
|
|
747 | char *buf = SvPVbyte (sv, len); |
|
|
748 | |
|
|
749 | int tmphist[HISTSIZE]; |
|
|
750 | float *hist; |
|
|
751 | |
|
|
752 | SV *histsv = newSV (HISTSIZE * sizeof (float) + 1); |
|
|
753 | SvPOK_on (histsv); |
|
|
754 | SvCUR_set (histsv, HISTSIZE * sizeof (float)); |
|
|
755 | hist = (float *)SvPVX (histsv); |
|
|
756 | |
|
|
757 | Zero (tmphist, sizeof (tmphist), char); |
|
|
758 | |
|
|
759 | for (j = len; j--; ) |
|
|
760 | { |
|
|
761 | unsigned int idx |
|
|
762 | = ((*buf & 0xc0) >> 2) |
|
|
763 | | ((*buf & 0x18) >> 1) |
|
|
764 | | (*buf & 0x03); |
|
|
765 | |
|
|
766 | ++tmphist[idx]; |
|
|
767 | ++buf; |
|
|
768 | } |
|
|
769 | |
|
|
770 | for (j = 0; j < HISTSIZE; ++j) |
|
|
771 | hist[j] = (float)tmphist[j] / (len + 1e-30); |
|
|
772 | |
|
|
773 | av_push (result, histsv); |
|
|
774 | } |
|
|
775 | |
|
|
776 | RETVAL = newRV_noinc ((SV *)result); |
|
|
777 | } |
|
|
778 | OUTPUT: |
|
|
779 | RETVAL |
|
|
780 | |
|
|
781 | |
|
|