2 |
2 |
|
3 |
3 |
import cz.zcu.kiv.aswi.fulltextsearch.document.*;
|
4 |
4 |
import cz.zcu.kiv.aswi.fulltextsearch.model.SearchResponse;
|
|
5 |
import javaxt.io.Image;
|
5 |
6 |
import org.apache.solr.client.solrj.SolrQuery;
|
6 |
7 |
import org.apache.solr.client.solrj.SolrServerException;
|
7 |
8 |
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
... | ... | |
297 |
298 |
textLine.setLineText((String) solrDocument.getFieldValue(lineName));
|
298 |
299 |
String coordsValue = (String) solrDocument.getFieldValue(lineName + SUFFIX_COORDS);
|
299 |
300 |
Point[] linePoints = Coords.parsePointString(coordsValue);
|
|
301 |
|
|
302 |
//-----
|
|
303 |
for (Point p: linePoints){
|
|
304 |
p.setX(p.getX() - textRegion.getRegionCoords().getPoints()[0].getX());
|
|
305 |
p.setY(p.getY() - textRegion.getRegionCoords().getPoints()[0].getY());
|
|
306 |
}
|
|
307 |
//-----
|
|
308 |
|
300 |
309 |
textLine.setLineCoords(new Coords(linePoints));
|
301 |
310 |
|
302 |
311 |
textLines.put(lineName, textLine);
|
... | ... | |
309 |
318 |
textWord.setWordText((String) solrDocument.getFieldValue(wordName));
|
310 |
319 |
String coordsValue = (String) solrDocument.getFieldValue(wordName + SUFFIX_COORDS);
|
311 |
320 |
Point[] wordPoints = Coords.parsePointString(coordsValue);
|
|
321 |
|
|
322 |
//-----
|
|
323 |
for (Point p: wordPoints){
|
|
324 |
p.setX(p.getX() - textRegion.getRegionCoords().getPoints()[0].getX());
|
|
325 |
p.setY(p.getY() - textRegion.getRegionCoords().getPoints()[0].getY());
|
|
326 |
}
|
|
327 |
//-----
|
|
328 |
|
312 |
329 |
textWord.setWordCoords(new Coords(wordPoints));
|
313 |
330 |
|
314 |
331 |
String lineName = wordName.substring(wordName.indexOf(PREFIX_TEXT_LINE));
|
... | ... | |
329 |
346 |
|
330 |
347 |
textRegion.setTextLines(textLines.values().toArray(new TextLine[0]));
|
331 |
348 |
|
332 |
|
// image
|
|
349 |
// cropping image
|
333 |
350 |
String imgFilename = (String) solrDocument.getFieldValue(FIELD_IMG_FILENAME);
|
334 |
351 |
byte[] imageBytes = getImageFromFilesCore(imgFilename);
|
|
352 |
|
|
353 |
BufferedImage img = ImageIO.read(new ByteArrayInputStream(Base64.getDecoder().decode(imageBytes)));
|
|
354 |
Image cropImg = new Image(img);
|
|
355 |
cropImg.crop(textRegion.getRegionCoords().getPoints()[0].getX(),textRegion.getRegionCoords().getPoints()[0].getY(),
|
|
356 |
textRegion.getRegionCoords().getPoints()[1].getX()-textRegion.getRegionCoords().getPoints()[0].getX(),
|
|
357 |
textRegion.getRegionCoords().getPoints()[2].getY()-textRegion.getRegionCoords().getPoints()[0].getY());
|
|
358 |
|
|
359 |
cropImg.setOutputQuality(0.5f);
|
|
360 |
|
|
361 |
//imageBytes = cropImg.getByteArray();
|
|
362 |
Base64.getEncoder().encode(cropImg.getByteArray());
|
|
363 |
|
|
364 |
// recalculating Coords - during init for words and lines
|
|
365 |
for (int k = 1; k<textRegion.getRegionCoords().getPoints().length; k++){
|
|
366 |
textRegion.getRegionCoords().getPoints()[k].setX(textRegion.getRegionCoords().getPoints()[k].getX() - textRegion.getRegionCoords().getPoints()[0].getX());
|
|
367 |
textRegion.getRegionCoords().getPoints()[k].setY(textRegion.getRegionCoords().getPoints()[k].getY() - textRegion.getRegionCoords().getPoints()[0].getY());
|
|
368 |
}
|
|
369 |
textRegion.getRegionCoords().getPoints()[0].setX(0);
|
|
370 |
textRegion.getRegionCoords().getPoints()[0].setY(0);
|
|
371 |
|
335 |
372 |
textRegion.setImageCut(new String(imageBytes));
|
336 |
373 |
|
337 |
374 |
// image size
|
Re #7815: Vyřezávání obrázků dle zadaných souřadnic
- úprava metody Query k ořezávání obrázků