Changeset 37011


Ignore:
Timestamp:
2022-12-10T18:21:36+13:00 (17 months ago)
Author:
davidb
Message:

Collection now correctly displays OCR bounding-boxes on each page of an Item file

Location:
gs3-installations/intermuse/trunk/sites/intermuse/collect/programmes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gs3-installations/intermuse/trunk/sites/intermuse/collect/programmes/js/document_viewer.js

    r36997 r37011  
    1 function load_gv_dococr_json(json_file, callback) {
     1function load_gv_dococr_json(json_file,doc_sec_id,callback) {
    22
    33    var http_assocfilepath = gs.collectionMetadata["httpPath"]+"/index/assoc/"+gs.documentMetadata["assocfilepath"];
     
    1313        })
    1414        .done(function(gv_ocr_json_result) {
    15         callback(gv_ocr_json_result);
     15        callback(gv_ocr_json_result,doc_sec_id);
    1616
    1717        });
     
    1919}
    2020
    21 function display_gv_ocr_bounding_boxes(gv_ocr_json)
     21function display_gv_ocr_bounding_boxes(gv_ocr_json,doc_sec_id)
    2222{
    2323    console.log(gv_ocr_json);
     
    7171
    7272       
    73     display_scaled_div_bounding_boxes(bounding_box_rects, page_x_dim,page_y_dim);
     73    display_scaled_div_bounding_boxes(doc_sec_id, bounding_box_rects, page_x_dim,page_y_dim);
    7474   
    7575    }
     
    8282
    8383
    84 function display_scaled_div_bounding_boxes(bounding_box_rects,fullsize_x_dim,fullsize_y_dim)
     84function display_scaled_div_bounding_boxes(doc_sec_id, bounding_box_rects,fullsize_x_dim,fullsize_y_dim)
    8585{
    8686    var screen_x_dim = gs.variables.screenImageWidth;
     
    9393    //console.log("scale y = " + scale_y);
    9494   
    95     var docID = gs.variables.d;   
    96     var screen_image_id = "small"+docID;
     95    var screen_image_id = "small"+doc_sec_id;
    9796
    9897    var $boundingbox_overlay = $("<div>")
    99     .attr("id","ocr-boundingbox-overlay-"+docID)
     98    .attr("id","ocr-boundingbox-overlay-"+doc_sec_id)
    10099    .attr("class","ocr-boundingbox-overlay");
    101100
  • gs3-installations/intermuse/trunk/sites/intermuse/collect/programmes/transform/pages/document.xsl

    r36997 r37011  
    3838    <xsl:attribute name="href">
    3939      <xsl:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name = 'httpPath']"/>
    40       <xsl:text>/index/assoc/</xsl:text><xsl:value-of disable-output-escaping="yes" select="$assocfilepath" /><xsl:text>/</xsl:text>enable_document_ocrgoogle-vision-output.json
     40      <xsl:text>/index/assoc/</xsl:text><xsl:value-of disable-output-escaping="yes" select="$assocfilepath" /><xsl:text>/</xsl:text>gv_document_ocrgoogle-vision-output.json
    4141    </xsl:attribute>
    42     enable_document_ocrgoogle-vision-output.json
     42    gv_document_ocrgoogle-vision-output.json
    4343      </a>
    4444    </div>
     45    <gsf:variable name="GVDocumentOCRJSON"><gsf:metadata name="GVDocumentOCRJSON"/></gsf:variable>
     46    <gsf:variable name="docSectionID"><xsl:value-of select="util:replace(@nodeID, '.', '_')}"/></gsf:variable>
    4547    <gsf:script>
    46       load_gv_dococr_json("enable_document_ocrgoogle-vision-output.json",display_gv_ocr_bounding_boxes);
     48      load_gv_dococr_json(gs.variables.GVDocumentOCRJSON,gs.variables.docSectionID,display_gv_ocr_bounding_boxes);
    4749    </gsf:script>
    4850  </xsl:template>
    4951
    50 <!--
    51   <xsl:template name="sectionPre">
    52     OCR'd Text:
    53   </xsl:template>
    5452
    55   <xsl:template name="documentPre">
    56     OCR'd Text:
    57   </xsl:template>
    58 -->
     53  <xsl:template name="wrappedSectionPost">
    5954
    60   <xsl:template name="sectionPost">
    6155    <!-- add in IIIF Server link for section image -->
    6256    <xsl:variable name="nodeID" select="@nodeID"/>
     
    6458      <xsl:with-param name="identifier" select="$nodeID" />
    6559    </xsl:call-template>
     60
    6661    <!-- add in Google Vision OCR JSON link for section image -->
    6762    <xsl:call-template name="googlevision-ocr-json">
    6863      <xsl:with-param name="assocfilepath"><gsf:metadata name="assocfilepath" select="root"/></xsl:with-param>
    6964    </xsl:call-template>   
     65
     66  </xsl:template>
     67
     68
     69  <xsl:template name="sectionContent">
     70    <xsl:call-template name="wrappedSectionImage"/>
     71    <div style="padding: 10px 0px 10px 0px">Ocr'd Text:</div>
     72    <i>
     73      <xsl:call-template name="wrappedSectionText"/>
     74    </i>
     75    <xsl:call-template name="wrappedSectionPost"/>
     76  </xsl:template>
     77 
     78  <xsl:template name="sectionContentForEditing">
     79    <xsl:call-template name="wrappedSectionImage"/>
     80    <xsl:call-template name="wrappedSectionTextForEditing"/>
    7081  </xsl:template>
    7182
     
    89100 
    90101  <xsl:template name="documentPost">
    91     <!-- add in IIIF Server link for simple page image -->
    92102    <xsl:if test="@docType='simple'">
     103      <!-- add in IIIF Server link for simple page image -->
    93104      <xsl:call-template name="iiif-links">
    94105    <xsl:with-param name="identifier" select="$docID" />
    95106      </xsl:call-template>
    96       <!-- add in Google Vision OCR JSON link for simple page image -->     
    97       <xsl:call-template name="googlevision-ocr-json">
    98     <xsl:with-param name="assocfilepath"><gsf:metadata name="assocfilepath" pos="first"/></xsl:with-param>
    99       </xsl:call-template>
     107
     108      <!--
     109      <gsf:switch>
     110    <gsf:metadata name='HasGoogleVisionDocumentOCRJSON";'/>
     111      <gsf:when test='equals' test-value="1">
     112      -->
     113
     114      <!-- add in Google Vision OCR JSON link for simple page image -->     
     115      <xsl:call-template name="googlevision-ocr-json">
     116        <xsl:with-param name="assocfilepath"><gsf:metadata name="assocfilepath" pos="first"/></xsl:with-param>
     117      </xsl:call-template>
     118      <!--
     119    </gsf:when>
     120      </gsf:switch>
     121-->
     122     
    100123    </xsl:if>   
    101124  </xsl:template>
Note: See TracChangeset for help on using the changeset viewer.