How are the java files in package org.sikuli.basics.proxies generated from C/C++ code using SWIG ?
Hi RaiMan,
I'm new to using SWIG. I've seen some short tutorial on how to generate example.java from example.c here (http://
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- SikuliX Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- RaiMan
- Solved:
- Last query:
- Last reply:
Revision history for this message
![]() |
#1 |
LOL, I am new to SWIG too ;-)
Your big advantage (which is my hope on getting further) is your much deeper knowledge about C/C++ (I can "read" C++ stuff, but until know I did not dare to make substantial changes to the native level))
This is the command file I once used to produce the "swigged" stuff on Windows (until I found out, that I only need to swig on my Mac and the generated stuff will be sufficient for building on Windows and Linux).
So this script might not exactly fit to the current source structure.
@echo off
setlocal
set BASE=%SIKDEVELOP%
set ODIR=%BASE%
set ICV=c:\
set IVISION=
set J1=%JDKHOME%
set J2=%JDKHOME%
set LOCAL=c:
set SWIGEXE=
echo on
%SWIGEXE% -java -package org.sikuli.
endlocal
ODIR - where the generated java goes
IVISION - the native sources
- this is the actual productive script I use on Mac
#!/bin/sh
odir=$DEVSRC/
icv=/usr/
ivision=
sysJava=
/usr/local/bin/swig -java -package org.sikuli.
Revision history for this message
![]() |
#2 |
BTW: I would prefer to discuss things like that directly on github.
Revision history for this message
![]() |
#3 |
Awesome, I tried this on my windows. It produced me all the java interfaces except openCV.java. I don't know the reason for it. Any ideas why this happened?
Also, regarding MinGW is it necessary to set it is an environment variable? I couldn't find the directory c:\MinGW\
Revision history for this message
![]() |
#4 |
- openCV.java ...
... is not generated by SWIG as you can see in the head of the file. It is simply some Java code, that I decided to be here.
- MinGW
as far as I understood: You are using Visual Studio and hence MinGW does not have any meaning to you (I hope, you did not install it, since it is a hard job to have both on the same machine).
What is found in my environment in c:\MinGW\
Since I did not run the Windows version of SWIG (if I ever did that), but the MinGW version (hence the Unix/Linux version), SWIG seemed to need some include file.
If this is not on your system and SWIG does not complain anything: just be happy.
Revision history for this message
![]() |
#5 |
Okay, cool.
after all this hard work too, even now I cannot link dll to java code. I don't know where I went wrong. still exploring on this.
anyways, my ultimate goal is to remove the integration of tesseract (for my custom project) with sikuli-ide as tesseract is not developed to identify text on screens. The normal DPI we have on our screens is 96 DPI. They recommend a minimum of 200 or 300 DPI. Tess is best for scanned documents as the DPI there is generally higher. I did a lot of research on this and found that screen font OCR is disturbed by a lot of factors such as ClearType and AntiAliasing etc... So, I decided not to use Vector Fonts on my system as MS uses some patented Font Rasterization technique to introduce the above funky effects. I'm using only raster (bitmap) fonts for all my applications now. So, I now do a pixel comparison (in other words template matching, where I have templates of each character stored in some folder) to identify the location of the character on the screen. This is my text finding idea.
so, for this if I knew the exact procedure to how to build sikuli-ide from scratch, I thought it'd be useful for me to integrate my code into the existing one. The fight still continues. ;)
Well, for the following error
[error] java.lang.
which I posted as a different question you said
"seems that your build procedure does not yet produce a useable VisionProxy at the moment.
VisionProxyJNI.
To know the all entries in VisionProxy.dll (which are in VisionProxyJNI.
Please confirm the above assumptions of mine. This time I'll struggle more to finally resolve this.
Revision history for this message
![]() |
#6 |
ok, understood.
With the problems you have, I cannot help you further: I never did before, what you do and I only know in the moment, that my build processes produce valid libraries for Mac, Windows and Linux (Ubuntu).
And that is what I want. I have no idea about what is wrong with your build process.
When I had problems with missing dependencies, I successfully used a dependency walker.
In a few weeks I will start to step down to the native level, but in the moment I have other priorities - sorry.
Revision history for this message
![]() |
#7 |
In my VisionProxy.dll, I cannot find any entry points. If you have any idea about this, please reply or else I'll resolve by googling and come here to post solution here soon. Thanks for spending your valuable time. :)
Revision history for this message
![]() |
#8 |
Hi RaiMan,
Finally found out the reason for findFailed of my case. The reason is while making a SWIG call it fails to set the target. Target has correct path and correct type, but the target->data (and target->datastart and target->dataend) is null. That is why in find function in native level it does not produce proper result and find is failed. Since VisionJAVA_wrap.cxx is an auto-generated file, I didn't dare to make changes. You have any ideas where might this might be gone wrong ? Is it because of wrong vision.i ?
Btw, I attached running sikuli-ide.jar (java.exe) before it calls VisionProxy.dll to my Visual Studio and started debugging :)
Revision history for this message
![]() |
#9 |
for me the situation has not changed ;-)
... but I just setup a Windows 8 Pro64 and I am on the way to setup my development environment (NetBeans7.4, VS Express 2013 for Desktop) and I already successfully built WinUtil.dll :-)
So I guess, within the next 2 weeks I am on the road with this.
I will tell you if I have any idea in between.
My next steps: build 64-Bit versions of OpenCV and Tesseract (I will the be able to build the 32-Bit versions too)
--- but the target->data (and target->datastart and target->dataend) is null.
Where in the code can I see this?
As already mentioned, I would prefer to communicate directly per mail,to easily add attachments.
my mail: look at https:/
Revision history for this message
![]() |
#10 |
Just to recall,
In VisionJAVA_wrap.cxx there are following 4 functions (there are others too, but they don't bother us at the moment ;) ),
For source:
Java_org_
Java_org_
For target:
Java_org_
Java_org_
for source, Java_org_
and for target, only Java_org_
Does this mean target is not properly read ? Any ideas why this is happening ?
Revision history for this message
![]() |
#11 |
-- target->data (and target->datastart and target->dataend)
these are all not in the code. But, I can see their values using VisualStudio debugger. arg3 is a pointer in VisionJAVA_wrap.cxx and arg3->target->data is the image data, which contains the RGB values obtained by reading the image stored in form of ASCII characters.
To simplify,
In Vision.cpp, the following code section when called in find_image functions returns a target whose rows = 0, columns = 0, but I can see the target in the path with my eyes.
Mat
FindInput:
return target;
}
Revision history for this message
![]() |
#12 |
This simply means, that before the FindInput structure was not filled with a target image.
Again the process on the Java level, when a find operation is fired:
- a Finder object is initiated with a source image, which leads to the init of a FindInput structure
- somehow Finder.find(image) is called which results in adding the image to the FindInput structure
- then on the native level find(FindInput) is called
BTW: pls. switch to private communication. I will no longer answer on this three.
Revision history for this message
![]() |
#13 |
Sorry for still replying. But I wanted to say that I solved the problem entirely and the mistake is that in vision.cpp in line-88, the case for target_
Kindly approve it. Thanks for your support all the way. You really rock :)
I can now start my hacking all the way.
Revision history for this message
![]() |
#14 |
Thanks RaiMan, that solved my question.