Closed Artgit closed 6 years ago
I think you would need to call regTestSetup
to properly set up L_RegParams rp
. That may be tricky to implement. If all that you try fail, I would suggest not using L_RegParams
variable and replacing regTestWritePixAndCheck
call with simpler pixWrite
method.
Doc on regTestSetup
API:
http://misc.voidlinux.de/html/regutils_8c.html#a1ed38b553c1fd2997ba6797fc359bf5a
Exactly correct. This was set up as a regression test which uses the leptonica regression framework; in particular, the L_RegParams struct. It is not required for using the method.
Thanks for your answers. I have removed logic with L_RegParams. But I still having issue with the following code:
Leptonica1.selDestroy(new PointerByReference(sel1.getPointer()));
Leptonica1.selDestroy(new PointerByReference(sel2.getPointer()));
Leptonica1.selDestroy(new PointerByReference(sel3.getPointer()));
Leptonica1.selDestroy(new PointerByReference(sel4.getPointer()));
Leptonica1.pixDestroy(new PointerByReference(pix2.getPointer()));
Leptonica1.pixaDestroy(new PointerByReference(pixa1.getPointer()));
I'm doing something wrong here because when this code is uncommented I have the following exception: Exception in thread "main" java.lang.Error: Invalid memory access
How to correctly destroy Sels objects?
I experienced no issue with running the code.
Sorry, I forgot to add the code that causes the issue:
Leptonica instance = Leptonica.INSTANCE;
instance.pixWrite("result.png", pixs9, ILeptonica.IFF_PNG);
@nguyenq could you please try with these lines?
New despeckle
method, based on Leptonica's speckle_reg.c
example, and its test case have been incorporated into the baseline. You can try it out.
@nguyenq thanks! I tested despeckle
method.
The following code works fine:
Leptonica instance = Leptonica.INSTANCE;
Pix pixs = instance.pixRead("w91frag.jpg");
Leptonica1.pixDisplayWrite(pixs, 1);
pixs = LeptUtils.despeckle(pixs, LeptUtils.SEL_STR2, 2);
instance.pixWrite("result.png", pixs, ILeptonica.IFF_PNG);
The following code doesn't work(with the second invocation of despeckle method the result.png has 0 bytes):
Leptonica instance = Leptonica.INSTANCE;
Pix pixs = instance.pixRead("w91frag.jpg");
Leptonica1.pixDisplayWrite(pixs, 1);
pixs = LeptUtils.despeckle(pixs, LeptUtils.SEL_STR2, 2);
pixs = LeptUtils.despeckle(pixs, LeptUtils.SEL_STR3, 3);
instance.pixWrite("result.png", pixs, ILeptonica.IFF_PNG)
What am I doing wrong?
Based on the original C example, the second invocation should not be called on the result pix of a previous invocation but rather on the original pix.
Also, reassigning pix variables is not a recommended practice for Leptonica. It leads to memory leaks as the previous pix's resource is not released; it needs to be disposed. Use a new instance of pix, instead.
Thanks!
I'm trying to port the following C code https://github.com/DanBloomberg/leptonica/blob/master/prog/speckle_reg.c to Java lept4j
This is my current version:
Everything works fine except the last code block(commented).
rp
variable is null and code fails. How to properly convert this code?