source: gs3-extensions/structured-image/trunk/perllib/plugins/GoogleVisionPagedImagePlugin.pm@ 37000

Last change on this file since 37000 was 37000, checked in by davidb, 17 months ago

Changes after testing

File size: 3.0 KB
Line 
1###########################################################################
2#
3# GoogleVisionPagedImagePlugin.pm -- plugin that adds Google Vision API
4# capabilities on top of PageImagePlugin
5#
6# A component of the Greenstone digital library software
7# from the New Zealand Digital Library Project at the
8# University of Waikato, New Zealand.
9#
10# Copyright (C) 1999 New Zealand Digital Library Project
11#
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, write to the Free Software
24# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25#
26###########################################################################
27
28
29# See PagedImagePlugin for more details
30
31package GoogleVisionPagedImagePlugin;
32
33#use Encode;
34#use ReadXMLFile;
35#use ReadTextFile;
36use GoogleVisionAPIConverter;
37use PagedImagePlugin;
38
39use strict;
40no strict 'refs'; # allow filehandles to be variables and viceversa
41
42sub BEGIN {
43 @GoogleVisionPagedImagePlugin::ISA = ('PagedImagePlugin', 'GoogleVisionAPIConverter');
44}
45
46
47my $arguments = [];
48
49my $options = { 'name' => "GoogleVisionPagedImagePlugin",
50 'desc' => "{GoogleVisionPagedImagePlugin.desc}",
51 'abstract' => "no",
52 'inherits' => "yes",
53 'args' => $arguments };
54
55sub new {
56
57 my ($class) = shift (@_);
58 my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
59 push(@$pluginlist, $class);
60
61 push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
62 push(@{$hashArgOptLists->{"OptList"}},$options);
63
64 new GoogleVisionAPIConverter($pluginlist, $inputargs, $hashArgOptLists, 1);
65 my $self = new PagedImagePlugin($pluginlist, $inputargs, $hashArgOptLists);
66
67 return bless $self, $class;
68}
69
70
71#sub init {
72# my $self = shift (@_);
73# my ($verbosity, $outhandle, $failhandle) = @_;
74#
75# $self->SUPER::init(@_);
76# $self->GoogleVisionAPIConverter::init();
77#}
78
79sub begin {
80 my $self = shift (@_);
81 my ($pluginfo, $base_dir, $processor, $maxdocs) = @_;
82
83 $self->SUPER::begin(@_);
84 $self->GoogleVisionAPIConverter::begin(@_);
85}
86
87
88sub process_image {
89 my $self = shift(@_);
90 my ($filename_full_path, $filename_no_path, $doc_obj, $section, $rotate) = @_;
91
92 my $utf8_filename_no_path = $self->filepath_to_utf8($filename_no_path);
93 my $url_encoded_filename = &util::rename_file($utf8_filename_no_path, $self->{'file_rename_method'});
94
95 $self->run_gv_convert($filename_full_path,$url_encoded_filename,$doc_obj,$section);
96
97 return $self->SUPER::process_image(@_);
98}
99
1001;
Note: See TracBrowser for help on using the repository browser.