java.awt.BasicStroke Scala Examples
The following examples show how to use java.awt.BasicStroke.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: Utils.scala From BigDL with Apache License 2.0 | 5 votes |
package com.intel.analytics.bigdl.dataset.image import java.awt.image.BufferedImage import java.awt.{BasicStroke, Color, Font, Graphics2D} import java.io.File import java.nio.file.Paths import javax.imageio.ImageIO import com.intel.analytics.bigdl.tensor.Tensor def visDetection(imagePath: String, clsname: String, scores: Tensor[Float], bboxes: Tensor[Float], thresh: Float = 0.3f, outPath: String = "data/demo"): Unit = { val f = new File(outPath) if (!f.exists()) { f.mkdirs() } val path = Paths.get(outPath, s"${ clsname }_${ imagePath.substring(imagePath.lastIndexOf("/") + 1) }").toString vis(imagePath, clsname, scores, bboxes, path, thresh) } }
Example 2
Source File: TestOCR.scala From AppCrawler with Apache License 2.0 | 5 votes |
class TestOCR extends FunSuite{ test("test ocr"){ val api=new Tesseract() api.setDatapath("/Users/seveniruby/Downloads/") api.setLanguage("eng+chi_sim") val img=new java.io.File("/Users/seveniruby/temp/google-test7.png") val imgFile=ImageIO.read(img) val graph=imgFile.createGraphics() graph.setStroke(new BasicStroke(5)) val result=api.doOCR(img) val words=api.getWords(imgFile, TessPageIteratorLevel.RIL_WORD).toList words.foreach(word=>{ val box=word.getBoundingBox val x=box.getX.toInt val y=box.getY.toInt val w=box.getWidth.toInt val h=box.getHeight.toInt graph.drawRect(x, y, w, h) graph.drawString(word.getText, x, y) println(word.getBoundingBox) println(word.getText) }) graph.dispose() ImageIO.write(imgFile, "png", new java.io.File(s"${img}.mark.png")) println(result) } } */
Example 3
Source File: Graphics2DRenderContextSpec.scala From evilplot with BSD 3-Clause "New" or "Revised" License | 5 votes |
package com.cibo.evilplot.geometry import java.awt.image.BufferedImage import java.awt.{BasicStroke, Color, Graphics2D} import org.scalatest.{FunSpec, Matchers} class Graphics2DRenderContextSpec extends FunSpec with Matchers with Graphics2DSupport { describe("state stack operations") { it("The state should be the same before and after a stack op.") { val graphics = Graphics2DTestUtils.graphics2D val ctx = Graphics2DRenderContext(graphics) val GraphicsState(initialTransform, initialFill, initialColor, initialStroke) = ctx.initialState Graphics2DRenderContext.applyOp(ctx) { ctx.graphics.translate(34, 20) ctx.graphics.setPaint(Color.BLUE) ctx.graphics.setStroke(new BasicStroke(3)) } ctx.graphics.getTransform shouldBe initialTransform ctx.fillColor shouldBe initialFill ctx.strokeColor shouldBe initialColor ctx.graphics.getStroke shouldBe initialStroke } } } object Graphics2DTestUtils { def graphics2D: Graphics2D = { val bi = new BufferedImage(800, 600, BufferedImage.TYPE_INT_ARGB) bi.createGraphics() } }