Protector-it.org methode (Plugin fehlt noch)ColoredLetterComperator LoadCaptcha speichert jetzt die informationen kann auch in Plugins verwendet werden siehe LoadAgain
git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@7671 ebf7c1c2-ba36-0410-9fe8-c592906822b4
133
ressourcen/jd/captcha/methods/protect-it.org/bgimages.xml
Normal file
@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<java version="1.6.0_14" class="java.beans.XMLDecoder">
|
||||
<object class="java.util.Vector">
|
||||
<void method="add">
|
||||
<object class="jd.captcha.easy.BackGroundImage">
|
||||
<void property="backgroundImage">
|
||||
<string>mask_f2fbdcd60265f6ced0019a583441acee.png</string>
|
||||
</void>
|
||||
<void property="color">
|
||||
<int>-3151923</int>
|
||||
</void>
|
||||
<void property="colorDistanceMode">
|
||||
<byte>3</byte>
|
||||
</void>
|
||||
<void property="distance">
|
||||
<int>1</int>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
<void method="add">
|
||||
<object class="jd.captcha.easy.BackGroundImage">
|
||||
<void property="backgroundImage">
|
||||
<string>mask_c7c04b56d7c9721a12ca8aa3dfa5763c.png</string>
|
||||
</void>
|
||||
<void property="color">
|
||||
<int>-3151923</int>
|
||||
</void>
|
||||
<void property="colorDistanceMode">
|
||||
<byte>3</byte>
|
||||
</void>
|
||||
<void property="distance">
|
||||
<int>1</int>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
<void method="add">
|
||||
<object class="jd.captcha.easy.BackGroundImage">
|
||||
<void property="backgroundImage">
|
||||
<string>mask_1250852030683.png</string>
|
||||
</void>
|
||||
<void property="color">
|
||||
<int>-3151923</int>
|
||||
</void>
|
||||
<void property="colorDistanceMode">
|
||||
<byte>3</byte>
|
||||
</void>
|
||||
<void property="distance">
|
||||
<int>1</int>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
<void method="add">
|
||||
<object class="jd.captcha.easy.BackGroundImage">
|
||||
<void property="backgroundImage">
|
||||
<string>mask_19674a58038c03176459809579a48c9c.png</string>
|
||||
</void>
|
||||
<void property="color">
|
||||
<int>-3151923</int>
|
||||
</void>
|
||||
<void property="colorDistanceMode">
|
||||
<byte>3</byte>
|
||||
</void>
|
||||
<void property="distance">
|
||||
<int>1</int>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
<void method="add">
|
||||
<object class="jd.captcha.easy.BackGroundImage">
|
||||
<void property="backgroundImage">
|
||||
<string>mask_1250852764590.png</string>
|
||||
</void>
|
||||
<void property="color">
|
||||
<int>-3151923</int>
|
||||
</void>
|
||||
<void property="colorDistanceMode">
|
||||
<byte>3</byte>
|
||||
</void>
|
||||
<void property="distance">
|
||||
<int>1</int>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
<void method="add">
|
||||
<object class="jd.captcha.easy.BackGroundImage">
|
||||
<void property="backgroundImage">
|
||||
<string>mask_1250852866838.png</string>
|
||||
</void>
|
||||
<void property="color">
|
||||
<int>-3151923</int>
|
||||
</void>
|
||||
<void property="colorDistanceMode">
|
||||
<byte>3</byte>
|
||||
</void>
|
||||
<void property="distance">
|
||||
<int>1</int>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
<void method="add">
|
||||
<object class="jd.captcha.easy.BackGroundImage">
|
||||
<void property="backgroundImage">
|
||||
<string>mask_1250852912310.png</string>
|
||||
</void>
|
||||
<void property="color">
|
||||
<int>-3151923</int>
|
||||
</void>
|
||||
<void property="colorDistanceMode">
|
||||
<byte>3</byte>
|
||||
</void>
|
||||
<void property="distance">
|
||||
<int>1</int>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
<void method="add">
|
||||
<object class="jd.captcha.easy.BackGroundImage">
|
||||
<void property="backgroundImage">
|
||||
<string>mask_1250852953468.png</string>
|
||||
</void>
|
||||
<void property="color">
|
||||
<int>-3151923</int>
|
||||
</void>
|
||||
<void property="colorDistanceMode">
|
||||
<byte>3</byte>
|
||||
</void>
|
||||
<void property="distance">
|
||||
<int>1</int>
|
||||
</void>
|
||||
</object>
|
||||
</void>
|
||||
</object>
|
||||
</java>
|
BIN
ressourcen/jd/captcha/methods/protect-it.org/example.png
Normal file
After Width: | Height: | Size: 78 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/Disk.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/Roteherz.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 6.9 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/apfel.png
Normal file
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 5.7 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/baer.png
Normal file
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 9.3 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/blau.png
Normal file
After Width: | Height: | Size: 277 B |
After Width: | Height: | Size: 4.5 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/bruecke.png
Normal file
After Width: | Height: | Size: 9.3 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 10 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/fenster.png
Normal file
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 11 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/firefox.png
Normal file
After Width: | Height: | Size: 8.1 KiB |
After Width: | Height: | Size: 7.3 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/frosch.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/fuchs.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/fussspur.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/gelb.png
Normal file
After Width: | Height: | Size: 266 B |
After Width: | Height: | Size: 5.5 KiB |
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 5.1 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/katze.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/kuhkopf.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/lock.png
Normal file
After Width: | Height: | Size: 8.3 KiB |
After Width: | Height: | Size: 3.9 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/mario.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/maus.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/moeye.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/quad.png
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/rot.png
Normal file
After Width: | Height: | Size: 179 B |
After Width: | Height: | Size: 10 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/schlange.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/schloss.png
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/tanne.png
Normal file
After Width: | Height: | Size: 9.3 KiB |
After Width: | Height: | Size: 11 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/tracktor.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/trompete.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/wasser.png
Normal file
After Width: | Height: | Size: 8.1 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/windrad.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
ressourcen/jd/captcha/methods/protect-it.org/images/youtube.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
4
ressourcen/jd/captcha/methods/protect-it.org/jacinfo.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<jDownloader>
|
||||
<method name="protect-it.org" author="DwD" />
|
||||
<format type="png" letterNum="20" />
|
||||
</jDownloader>
|
41
ressourcen/jd/captcha/methods/protect-it.org/letters.mth
Normal file
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<jDownloader>
|
||||
<letter bad="0" captchaHash="871baac49349cedffb0867182b18454d" good="24" id="0" value="z">00000|11101|11011|10111|01111|00000</letter>
|
||||
<letter bad="0" captchaHash="895cf02ab4f0f657d37c97eee1671e14" good="5" id="1" value="y">01110|01110|10101|10101|11011|11011|11011|11011</letter>
|
||||
<letter bad="0" captchaHash="9b70ba0dfbb972b0de43f47ebb68bbae" good="5" id="2" value="x">01110|10101|11011|11011|10101|01110</letter>
|
||||
<letter bad="0" captchaHash="0e752f7fb42851424e1cf81f04e7bf55" good="17" id="3" value="w">01110|01110|01010|01010|01010|01010|00100|10101</letter>
|
||||
<letter bad="0" captchaHash="895cf02ab4f0f657d37c97eee1671e14" good="87" id="4" value="u">01110|01110|01110|01110|01100|10010</letter>
|
||||
<letter bad="0" captchaHash="0e752f7fb42851424e1cf81f04e7bf55" good="92" id="5" value="t">10111|10111|00001|10111|10111|10111|10110|11001</letter>
|
||||
<letter bad="1" captchaHash="871baac49349cedffb0867182b18454d" good="29" id="6" value="t">00000|11011|11011|11011|11011|11011|11011|11011</letter>
|
||||
<letter bad="0" captchaHash="0e752f7fb42851424e1cf81f04e7bf55" good="121" id="7" value="s">10001|01110|10011|11101|01110|10001</letter>
|
||||
<letter bad="0" captchaHash="beb88020dff43b2d185fe3c5f7e9302c" good="10" id="8" value="s">10001|01110|01111|10011|11101|11110|01110|10001</letter>
|
||||
<letter bad="0" captchaHash="0e752f7fb42851424e1cf81f04e7bf55" good="139" id="9" value="r">01001|00110|01111|01111|01111|01111</letter>
|
||||
<letter bad="0" captchaHash="b73fbbcc24a28f3d571a9bf0c934912d" good="3" id="10" value="R">00001|01110|01110|01110|00001|01011|01101|01110</letter>
|
||||
<letter bad="0" captchaHash="6926213e0a0219165221363daf5a6ab0" good="5" id="11" value="q">10001|01110|01110|01110|01110|01110|01010|10001|11110</letter>
|
||||
<letter bad="0" captchaHash="871baac49349cedffb0867182b18454d" good="50" id="12" value="p">01001|00110|01110|01110|00110|01001|01111</letter>
|
||||
<letter bad="1" captchaHash="808f595fbf646e6d49e42795927d3edc" good="100" id="13" value="o">10001|01110|01110|01110|01110|10001</letter>
|
||||
<letter bad="3" captchaHash="0e752f7fb42851424e1cf81f04e7bf55" good="116" id="14" value="n">01001|00110|01110|01110|01110|01110</letter>
|
||||
<letter bad="0" captchaHash="0b0cafa97eea9b14acc6d8fd80183749" good="20" id="15" value="m">01110|00100|01010|01010|01110|01110|01110|01110</letter>
|
||||
<letter bad="2" captchaHash="0e752f7fb42851424e1cf81f04e7bf55" good="107" id="16" value="l">001|101|101|101|101|101|101|000</letter>
|
||||
<letter bad="0" captchaHash="f3eafff7316a91864e6e15dc52427000" good="39" id="17" value="k">01111|01111|01101|01011|00111|01011|01101|01110</letter>
|
||||
<letter bad="0" captchaHash="8fe0c7e035c086d85bf4e70be90da8c7" good="5" id="18" value="k">01110|01110|01101|01011|00011|01101|01110|01110</letter>
|
||||
<letter bad="0" captchaHash="59bb0c617e4e3dbbcd7279616dce413a" good="6" id="19" value="j">1110|1110|1110|1110|1110|1110|0110|1001</letter>
|
||||
<letter bad="1" captchaHash="b110eb5c80d9cab02306fb7ea3cb7177" good="34" id="20" value="i">001|101|101|101|101|000</letter>
|
||||
<letter bad="0" captchaHash="b318414d625348ea02895cba20536718" good="64" id="21" value="h">01111|01111|01001|00110|01110|01110|01110|01110</letter>
|
||||
<letter bad="0" captchaHash="cf59936270fcffe6575fac9e063bdc7e" good="17" id="22" value="h">01110|01110|01110|00000|01110|01110|01110|01110</letter>
|
||||
<letter bad="0" captchaHash="b318414d625348ea02895cba20536718" good="11" id="23" value="g">11110|10001|01110|01110|10001|01111|10001|01110</letter>
|
||||
<letter bad="1" captchaHash="32bb2c3398dc53e7d14771445ae7997b" good="3" id="24" value="g">10001|01110|01111|01111|01100|01110|01110|10001</letter>
|
||||
<letter bad="1" captchaHash="808f595fbf646e6d49e42795927d3edc" good="35" id="25" value="f">00000|01111|01111|00001|01111|01111|01111|01111</letter>
|
||||
<letter bad="0" captchaHash="9b70ba0dfbb972b0de43f47ebb68bbae" good="30" id="26" value="f">11001|10110|10111|10111|00001|10111|10111|10111</letter>
|
||||
<letter bad="0" captchaHash="0e752f7fb42851424e1cf81f04e7bf55" good="221" id="27" value="e">10001|01110|00000|01111|01111|10001</letter>
|
||||
<letter bad="0" captchaHash="c4a7831f166a91131f1f848ebf725b45" good="13" id="28" value="e">00000|01111|01111|00001|01111|01111|01111|00000</letter>
|
||||
<letter bad="0" captchaHash="0e752f7fb42851424e1cf81f04e7bf55" good="54" id="29" value="d">11110|11110|10010|01100|01110|01110|01100|10010</letter>
|
||||
<letter bad="1" captchaHash="6a5486a480b05b19478decf23660bd46" good="4" id="30" value="D">00001|01110|01110|01110|01110|01110|01110|00001</letter>
|
||||
<letter bad="0" captchaHash="808f595fbf646e6d49e42795927d3edc" good="72" id="31" value="c">10001|01110|01111|01111|01110|10001</letter>
|
||||
<letter bad="0" captchaHash="59bb0c617e4e3dbbcd7279616dce413a" good="3" id="32" value="c">10001|01110|01111|01111|01111|01111|01110|10001</letter>
|
||||
<letter bad="1" captchaHash="895cf02ab4f0f657d37c97eee1671e14" good="24" id="33" value="b">01111|01111|01001|00110|01110|01110|00110|01001</letter>
|
||||
<letter bad="3" captchaHash="622b577d122e720be5bbd6a4e66ea2b4" good="17" id="34" value="b">00001|01110|01110|00001|01110|01110|01110|00001</letter>
|
||||
<letter bad="0" captchaHash="0e752f7fb42851424e1cf81f04e7bf55" good="103" id="35" value="a">10001|11110|10000|01110|01100|10010</letter>
|
||||
<letter bad="0" captchaHash="a49afb4945bd07976acd39d552663630" good="11" id="36" value="a">11011|10101|01110|01110|00000|01110|01110|01110</letter>
|
||||
<letter bad="1" captchaHash="0e752f7fb42851424e1cf81f04e7bf55" good="18" id="37" value="'">100|101|011</letter>
|
||||
</jDownloader>
|
After Width: | Height: | Size: 79 KiB |
After Width: | Height: | Size: 61 KiB |
After Width: | Height: | Size: 56 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 130 KiB |
After Width: | Height: | Size: 128 KiB |
After Width: | Height: | Size: 88 KiB |
41
ressourcen/jd/captcha/methods/protect-it.org/script.jas
Normal file
@ -0,0 +1,41 @@
|
||||
#####-------------------------------------JAC-Script--------------------------------------#####
|
||||
##### Automatisch erstellt mit EasyCaptcha #####
|
||||
##### #####
|
||||
##### #####
|
||||
#####################################---EasyCaptcha--######################################
|
||||
|
||||
|
||||
param.simplifyFaktor = 1;
|
||||
param.trainOnlyUnknown=true;
|
||||
param.colorType = RGB;
|
||||
|
||||
|
||||
param.borderVarianceX=5;
|
||||
param.borderVarianceY=5;
|
||||
param.scanVarianceX=5;
|
||||
param.scanVarianceY=5;
|
||||
|
||||
param.intersectionDimensionWeight=6.0;
|
||||
|
||||
param.scanAngleLeft=0;
|
||||
param.scanAngleRight=0;
|
||||
param.scanAngleSteps=0;
|
||||
|
||||
param.errorAWeight=4;
|
||||
param.errorBWeight=4;
|
||||
|
||||
param.coverageFaktorAWeight=1;
|
||||
param.coverageFaktorBWeight=0.2;
|
||||
|
||||
param.LetterSearchLimitPerfectPercent=0;
|
||||
param.quickScanReliabilityLimit=1;
|
||||
param.quickScanValityLimit=2;
|
||||
param.preScanFilter=100;
|
||||
param.preScanFaktor=3;
|
||||
param.preScanEmergencyFilter=80;
|
||||
param.objectColorContrast = 0.3;
|
||||
param.objectDetectionContrast = 0.5;
|
||||
param.relativecontrast=0.85;
|
||||
param.autoLetterNum=true;
|
||||
param.useSpecialGetLetters=ProtectItOrg.getLetters;
|
||||
param.useLetterFilter=ProtectItOrg.letterFilter;
|
237
src/jd/captcha/ColorLetterComperator.java
Normal file
@ -0,0 +1,237 @@
|
||||
package jd.captcha;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.jhlabs.image.PosterizeFilter;
|
||||
|
||||
import jd.captcha.pixelgrid.Captcha;
|
||||
|
||||
import jd.nutils.Colors;
|
||||
|
||||
import jd.captcha.pixelgrid.PixelGrid;
|
||||
import jd.captcha.pixelobject.PixelObject;
|
||||
import jd.captcha.utils.Utilities;
|
||||
import jd.captcha.pixelgrid.Letter;
|
||||
|
||||
public class ColorLetterComperator {
|
||||
private Letter a;
|
||||
private Letter b;
|
||||
private PixelObject[] aLayers;
|
||||
private PixelObject[] bLayers;
|
||||
private Captcha ca;
|
||||
private Captcha cb;
|
||||
private JAntiCaptcha owner;
|
||||
public int lettersPerfect = 2;
|
||||
public int lettersPerfectPercent = 20;
|
||||
public int maxColorDifference = 30;
|
||||
protected double valityPercent = 10000.0;
|
||||
/**
|
||||
* Farbebenen die untersucht werden sollen
|
||||
*/
|
||||
public int colorLevels = 2;
|
||||
|
||||
/**
|
||||
* vergleicht Farbebenen eignet sich um echte Bilder zu vergleichen
|
||||
*/
|
||||
public ColorLetterComperator(Letter a, Letter b) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
if (a.owner != null)
|
||||
owner = a.owner;
|
||||
else if (b.owner != null) owner = b.owner;
|
||||
}
|
||||
|
||||
public void setLetterA(Letter a) {
|
||||
this.a = a;
|
||||
ca=null;
|
||||
aLayers = null;
|
||||
}
|
||||
|
||||
public void setLetterB(Letter b) {
|
||||
this.b = b;
|
||||
cb=null;
|
||||
bLayers = null;
|
||||
}
|
||||
|
||||
private Letter getSWLetter(PixelObject obj) {
|
||||
int[][] lgrid = new int[obj.getWidth()][obj.getHeight()];
|
||||
for (int x = 0; x < obj.getWidth(); x++) {
|
||||
for (int y = 0; y < obj.getHeight(); y++) {
|
||||
lgrid[x][y] = 0xffffff;
|
||||
|
||||
}
|
||||
}
|
||||
int w = 0;
|
||||
for (int d = 0; d < obj.getSize(); d++) {
|
||||
w++;
|
||||
int[] akt = obj.elementAt(d);
|
||||
lgrid[akt[0] - obj.getXMin()][akt[1] - obj.getYMin()] = 0x000000;
|
||||
|
||||
}
|
||||
//invertieren wenn der schwarze bereich größer ist als der weiße
|
||||
if (obj.getArea() / 2 < w) {
|
||||
for (int x = 0; x < obj.getWidth(); x++) {
|
||||
for (int y = 0; y < obj.getHeight(); y++) {
|
||||
if (lgrid[x][y] == 0xffffff)
|
||||
lgrid[x][y] = 0x000000;
|
||||
else
|
||||
lgrid[x][y] = 0xffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
Letter l = obj.owner.createLetter();
|
||||
l.setElementPixel(obj.getSize());
|
||||
l.setLocation(new int[] { obj.getXMin(), obj.getYMin() });
|
||||
l.setGrid(lgrid);
|
||||
l.detected = obj.detected;
|
||||
return l;
|
||||
}
|
||||
/**
|
||||
* vergleicht alle Farbebenen die untersucht werden sollen und gibt den
|
||||
* durchschnittlichen ValityPercent
|
||||
*
|
||||
* @return Prozentwert 0(gut) bis 100 (schlecht) der Übereinstimmung
|
||||
*/
|
||||
public double run() {
|
||||
if (aLayers != null && bLayers != null) return valityPercent;
|
||||
if ((a.getArea() / 5) > b.getArea() || (b.getArea() / 5) > a.getArea()) {
|
||||
valityPercent = 10000.0;
|
||||
return valityPercent;
|
||||
}
|
||||
if(ca==null)
|
||||
{
|
||||
ca=reduceColors(a);
|
||||
}
|
||||
if(cb==null)
|
||||
{
|
||||
cb=reduceColors(b);
|
||||
}
|
||||
|
||||
if (aLayers == null) {
|
||||
aLayers = getObjects(ca);
|
||||
}
|
||||
if (bLayers == null) {
|
||||
bLayers = getObjects(cb);
|
||||
}
|
||||
double ret = 0;
|
||||
int minl = Math.min(aLayers.length, bLayers.length);
|
||||
int perf = 0;
|
||||
int maxl = Math.max(aLayers.length, bLayers.length);
|
||||
boolean minla = aLayers.length == minl;
|
||||
PixelObject[][] bestarray = new PixelObject[minl][2];
|
||||
for (int i = 0; i < minl; i++) {
|
||||
double best = Double.MAX_VALUE;
|
||||
PixelObject[] bestobj = null;
|
||||
for (int j = maxl - i - 1; j >= 0; j--) {
|
||||
double value = 0;
|
||||
int a = j;
|
||||
int b = i;
|
||||
|
||||
if (minla) {
|
||||
a = i;
|
||||
b = j;
|
||||
}
|
||||
value = Colors.getColorDifference(aLayers[a].getAverage(), bLayers[b].getAverage());
|
||||
|
||||
if (value == 0) {
|
||||
bestobj = new PixelObject[] { aLayers[a], bLayers[b] };
|
||||
break;
|
||||
} else if (value < best) {
|
||||
best = value;
|
||||
bestobj = new PixelObject[] { aLayers[a], bLayers[b] };
|
||||
}
|
||||
|
||||
}
|
||||
bestarray[i] = bestobj;
|
||||
}
|
||||
for (int i = 0; i < bestarray.length; i++) {
|
||||
if (Colors.getColorDifference(bestarray[i][0].getAverage(), bestarray[i][1].getAverage()) > maxColorDifference)
|
||||
ret += 100;
|
||||
else {
|
||||
try {
|
||||
Letter leta = getSWLetter(bestarray[i][0]);
|
||||
LetterComperator lc = new LetterComperator(leta, getSWLetter(bestarray[i][1]));
|
||||
lc.setOwner(getJac());
|
||||
bestarray[i][0].detected = lc;
|
||||
lc.run();
|
||||
double vall = lc.getValityPercent();
|
||||
if (vall < lettersPerfectPercent) {
|
||||
perf++;
|
||||
valityPercent = 0;
|
||||
if (perf == lettersPerfect) return 0;
|
||||
}
|
||||
ret += lc.getValityPercent();
|
||||
} catch (Exception e) {
|
||||
ret += ret / i;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
ret += (maxl - minl) * 100;
|
||||
valityPercent = ret / maxl;
|
||||
return valityPercent;
|
||||
}
|
||||
|
||||
private JAntiCaptcha getJac() {
|
||||
if (owner != null) return owner;
|
||||
String hoster = "EasyCaptcha";
|
||||
owner = new JAntiCaptcha(Utilities.getMethodDir(), hoster);
|
||||
return owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt aus jeder Farbebene ein Letter Achtung Farben müssen reduziert
|
||||
* sein
|
||||
*
|
||||
* @param grid
|
||||
* @return
|
||||
*/
|
||||
public static PixelObject[] getObjects(PixelGrid grid) {
|
||||
ArrayList<PixelObject> ret = new ArrayList<PixelObject>();
|
||||
ArrayList<PixelObject> merge;
|
||||
for (int x = 0; x < grid.getWidth(); x++) {
|
||||
for (int y = 0; y < grid.getHeight(); y++) {
|
||||
PixelObject n = new PixelObject(grid);
|
||||
n.add(x, y, grid.getGrid()[x][y]);
|
||||
|
||||
merge = new ArrayList<PixelObject>();
|
||||
for (PixelObject o : ret) {
|
||||
if (grid.getGrid()[x][y] == o.getAverage()) {
|
||||
merge.add(o);
|
||||
}
|
||||
}
|
||||
if (merge.size() == 0) {
|
||||
ret.add(n);
|
||||
} else if (merge.size() == 1) {
|
||||
merge.get(0).add(n);
|
||||
} else {
|
||||
for (PixelObject po : merge) {
|
||||
ret.remove(po);
|
||||
n.add(po);
|
||||
}
|
||||
ret.add(n);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return ret.toArray(new PixelObject[] {});
|
||||
}
|
||||
/**
|
||||
* reduziert die farben (colorLevels)
|
||||
*
|
||||
* @param letter
|
||||
* @return
|
||||
*/
|
||||
private Captcha reduceColors(Letter letter)
|
||||
{
|
||||
PosterizeFilter qf = new PosterizeFilter();
|
||||
BufferedImage image = (BufferedImage) letter.getImage();
|
||||
BufferedImage dest = qf.createCompatibleDestImage(image, ColorModel.getRGBdefault());
|
||||
qf.setNumLevels(colorLevels);
|
||||
qf.filter(image, dest);
|
||||
return getJac().createCaptcha(dest);
|
||||
}
|
||||
}
|
@ -218,6 +218,9 @@ public class BackGroundImageDialog implements ActionListener {
|
||||
return null;
|
||||
}
|
||||
}.waitForEDT();
|
||||
workingImage.setColor(colorChooser.getColor().getRGB());
|
||||
workingImage.setDistance((Integer) thresholdSpinner.getValue());
|
||||
workingImage.setColorDistanceMode(colorMode);
|
||||
ret = workingImage;
|
||||
return;
|
||||
} else if (e.getSource() == btLoadBackgroundImage) {
|
||||
|
@ -5,9 +5,7 @@ import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
import jd.captcha.pixelgrid.PixelGrid;
|
||||
|
||||
import jd.nutils.io.JDIO;
|
||||
|
||||
import jd.captcha.pixelgrid.Captcha;
|
||||
import jd.captcha.utils.Utilities;
|
||||
import jd.controlling.JDLogger;
|
||||
|
@ -20,6 +20,9 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
|
||||
import jd.captcha.easy.load.LoadCaptchas;
|
||||
|
||||
import jd.gui.userio.DummyFrame;
|
||||
import jd.JDInit;
|
||||
import jd.captcha.JAntiCaptcha;
|
||||
|
@ -9,6 +9,8 @@ import java.util.Vector;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import jd.captcha.easy.load.LoadCaptchas;
|
||||
|
||||
import jd.nutils.io.JDIO;
|
||||
|
||||
import jd.captcha.pixelgrid.Captcha;
|
||||
|
18
src/jd/captcha/easy/load/LoadAgain.java
Normal file
@ -0,0 +1,18 @@
|
||||
package jd.captcha.easy.load;
|
||||
|
||||
public class LoadAgain {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
LoadImage li = LoadImage.loadFile("teradepot.com");
|
||||
try {
|
||||
System.out.println(li.load("teradepot.com").file);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package jd.captcha.easy;
|
||||
package jd.captcha.easy.load;
|
||||
|
||||
import jd.utils.JDUtilities;
|
||||
import jd.http.Browser;
|
||||
@ -16,6 +16,8 @@ import java.io.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import jd.captcha.easy.EasyMethodeFile;
|
||||
|
||||
import jd.parser.html.HTMLParser;
|
||||
|
||||
import jd.parser.html.InputField;
|
||||
@ -39,6 +41,8 @@ public class LoadCaptchas {
|
||||
private ArrayList<LoadImage> images;
|
||||
private LoadImage selectedImage;
|
||||
private JFrame owner;
|
||||
public int maxHeight = 400;
|
||||
public int maxWeight = 600;
|
||||
/**
|
||||
* Ordner in den die Bilder geladen werden (default: jdCaptchaFolder/host)
|
||||
*
|
||||
@ -104,96 +108,100 @@ public class LoadCaptchas {
|
||||
new EasyMethodeFile(host).copyExampleImage();
|
||||
return true;
|
||||
}
|
||||
selectedImage = LoadImage.loadFile(host);
|
||||
if (selectedImage != null)
|
||||
selectedImage.load(host);
|
||||
else {
|
||||
dialog.setTitle(JDL.L("easycaptcha.loadcaptchas.clickoncaptcha", "click on the captcha"));
|
||||
images = getAllImages(br);
|
||||
loadImages();
|
||||
dialog.addWindowListener(new WindowListener() {
|
||||
|
||||
dialog.setTitle(JDL.L("easycaptcha.loadcaptchas.clickoncaptcha", "click on the captcha"));
|
||||
images = getAllImages(br);
|
||||
loadImages();
|
||||
dialog.addWindowListener(new WindowListener() {
|
||||
|
||||
public void windowActivated(WindowEvent e) {
|
||||
}
|
||||
|
||||
public void windowClosed(WindowEvent e) {
|
||||
|
||||
}
|
||||
|
||||
public void windowClosing(WindowEvent e) {
|
||||
for (LoadImage loadImage : images) {
|
||||
loadImage.file.delete();
|
||||
public void windowActivated(WindowEvent e) {
|
||||
}
|
||||
dialog.dispose();
|
||||
}
|
||||
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
}
|
||||
public void windowClosed(WindowEvent e) {
|
||||
|
||||
public void windowDeiconified(WindowEvent e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void windowIconified(WindowEvent e) {
|
||||
}
|
||||
|
||||
public void windowOpened(WindowEvent e) {
|
||||
}
|
||||
});
|
||||
|
||||
final ArrayList<JButton> bts = new ArrayList<JButton>();
|
||||
for (int j = 0; j < images.size(); j++) {
|
||||
final LoadImage f = images.get(j);
|
||||
if (f == null || f.file == null || !f.file.exists() || f.file.length() < 100) continue;
|
||||
final BufferedImage captchaImage = JDImage.getImage(f.file);
|
||||
if (captchaImage == null) {
|
||||
f.file.delete();
|
||||
continue;
|
||||
}
|
||||
int area = captchaImage.getHeight(null) * captchaImage.getHeight(null);
|
||||
if (area < 50 || area > 50000 || captchaImage.getHeight(null) > 400 || captchaImage.getWidth(null) > 400 || captchaImage.getWidth(null) < 10 || captchaImage.getHeight(null) < 5) {
|
||||
f.file.delete();
|
||||
continue;
|
||||
}
|
||||
double faktor = Math.max((double) captchaImage.getWidth(null) / 100, (double) captchaImage.getHeight(null) / 100);
|
||||
final int width = (int) (captchaImage.getWidth(null) / faktor);
|
||||
final int height = (int) (captchaImage.getHeight(null) / faktor);
|
||||
try {
|
||||
JButton ic = new GuiRunnable<JButton>() {
|
||||
public JButton runSave() {
|
||||
return new JButton(new ImageIcon(captchaImage.getScaledInstance(width, height, Image.SCALE_SMOOTH)));
|
||||
public void windowClosing(WindowEvent e) {
|
||||
for (LoadImage loadImage : images) {
|
||||
loadImage.file.delete();
|
||||
}
|
||||
}.getReturnValue();
|
||||
ic.addActionListener(new ActionListener() {
|
||||
dialog.dispose();
|
||||
}
|
||||
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
}
|
||||
|
||||
public void windowDeiconified(WindowEvent e) {
|
||||
}
|
||||
|
||||
public void windowIconified(WindowEvent e) {
|
||||
}
|
||||
|
||||
public void windowOpened(WindowEvent e) {
|
||||
}
|
||||
});
|
||||
|
||||
final ArrayList<JButton> bts = new ArrayList<JButton>();
|
||||
for (int j = 0; j < images.size(); j++) {
|
||||
final LoadImage f = images.get(j);
|
||||
if (f == null || f.file == null || !f.file.exists() || f.file.length() < 100) continue;
|
||||
final BufferedImage captchaImage = JDImage.getImage(f.file);
|
||||
if (captchaImage == null) {
|
||||
f.file.delete();
|
||||
continue;
|
||||
}
|
||||
int area = captchaImage.getHeight(null) * captchaImage.getHeight(null);
|
||||
if (area < 50 || captchaImage.getHeight(null) > maxHeight || captchaImage.getWidth(null) > maxWeight || captchaImage.getWidth(null) < 10 || captchaImage.getHeight(null) < 5) {
|
||||
f.file.delete();
|
||||
continue;
|
||||
}
|
||||
double faktor = Math.max((double) captchaImage.getWidth(null) / 100, (double) captchaImage.getHeight(null) / 100);
|
||||
final int width = (int) (captchaImage.getWidth(null) / faktor);
|
||||
final int height = (int) (captchaImage.getHeight(null) / faktor);
|
||||
try {
|
||||
JButton ic = new GuiRunnable<JButton>() {
|
||||
public JButton runSave() {
|
||||
return new JButton(new ImageIcon(captchaImage.getScaledInstance(width, height, Image.SCALE_SMOOTH)));
|
||||
}
|
||||
}.getReturnValue();
|
||||
ic.addActionListener(new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
selectedImage = f;
|
||||
dialog.dispose();
|
||||
}
|
||||
});
|
||||
bts.add(ic);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
selectedImage = f;
|
||||
dialog.dispose();
|
||||
}
|
||||
});
|
||||
bts.add(ic);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
final JPanel panel = new GuiRunnable<JPanel>() {
|
||||
public JPanel runSave() {
|
||||
return new JPanel(new GridLayout((int) Math.ceil(((double) bts.size()) / 5), 5));
|
||||
}
|
||||
}.getReturnValue();
|
||||
for (JButton button : bts) {
|
||||
panel.add(button);
|
||||
|
||||
}
|
||||
new GuiRunnable<Object>() {
|
||||
public Object runSave() {
|
||||
dialog.add(new JScrollPane(panel));
|
||||
|
||||
dialog.pack();
|
||||
dialog.setLocation(Screen.getCenterOfComponent(owner, dialog));
|
||||
dialog.setAlwaysOnTop(true);
|
||||
dialog.setVisible(true);
|
||||
|
||||
return null;
|
||||
}
|
||||
}.waitForEDT();
|
||||
}
|
||||
final JPanel panel = new GuiRunnable<JPanel>() {
|
||||
public JPanel runSave() {
|
||||
return new JPanel(new GridLayout((int) Math.ceil(((double) bts.size()) / 5), 5));
|
||||
}
|
||||
}.getReturnValue();
|
||||
for (JButton button : bts) {
|
||||
panel.add(button);
|
||||
|
||||
}
|
||||
new GuiRunnable<Object>() {
|
||||
public Object runSave() {
|
||||
dialog.add(new JScrollPane(panel));
|
||||
|
||||
dialog.pack();
|
||||
dialog.setLocation(Screen.getCenterOfComponent(owner, dialog));
|
||||
dialog.setAlwaysOnTop(true);
|
||||
dialog.setVisible(true);
|
||||
|
||||
return null;
|
||||
}
|
||||
}.waitForEDT();
|
||||
if (selectedImage != null && selectedImage.file != null) {
|
||||
loadProcess();
|
||||
if (opendir) openDir(dir);
|
||||
@ -306,7 +314,6 @@ public class LoadCaptchas {
|
||||
}
|
||||
}.getReturnValue();
|
||||
|
||||
|
||||
final JDTextField tfl = new GuiRunnable<JDTextField>() {
|
||||
public JDTextField runSave() {
|
||||
return new JDTextField();
|
||||
@ -401,7 +408,7 @@ public class LoadCaptchas {
|
||||
int menge = (Integer) sm.getValue();
|
||||
dialog.dispose();
|
||||
LoadInfo retLI = new LoadInfo(link, menge);
|
||||
retLI.followLinks=followLinks.isSelected();
|
||||
retLI.followLinks = followLinks.isSelected();
|
||||
return retLI;
|
||||
|
||||
}
|
||||
@ -493,7 +500,7 @@ public class LoadCaptchas {
|
||||
try {
|
||||
imagea = getImages(br);
|
||||
for (int i = 0; i < imagea.length; i++) {
|
||||
LoadImage li = new LoadImage(imagea[i], br);
|
||||
LoadImage li = new LoadImage(loadinfo, imagea[i], br);
|
||||
li.form = -1;
|
||||
li.location = i;
|
||||
images.add(li);
|
||||
@ -510,7 +517,7 @@ public class LoadCaptchas {
|
||||
brc.getPage(string);
|
||||
imagea = getImages(brc);
|
||||
for (int i = 0; i < imagea.length; i++) {
|
||||
LoadImage li = new LoadImage(imagea[i], brc);
|
||||
LoadImage li = new LoadImage(loadinfo, imagea[i], brc);
|
||||
li.form = -1;
|
||||
li.location = i;
|
||||
li.followUrl = b;
|
||||
@ -534,7 +541,7 @@ public class LoadCaptchas {
|
||||
imagea = getImages(brc);
|
||||
for (int b = 0; b < imagea.length; b++) {
|
||||
|
||||
LoadImage li = new LoadImage(imagea[b], brc);
|
||||
LoadImage li = new LoadImage(loadinfo, imagea[b], brc);
|
||||
li.form = i;
|
||||
li.location = b;
|
||||
if (images.contains(li)) continue;
|
||||
@ -569,7 +576,7 @@ public class LoadCaptchas {
|
||||
|
||||
public void run() {
|
||||
LoadImage image = images.get(i);
|
||||
image.load(dir);
|
||||
image.directCaptchaLoad(dir);
|
||||
synchronized (jb[i]) {
|
||||
jb[i].notify();
|
||||
}
|
||||
@ -634,11 +641,15 @@ public class LoadCaptchas {
|
||||
final Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
if(images!=null)
|
||||
{
|
||||
for (LoadImage loadImage : images) {
|
||||
if (!loadImage.file.equals(selectedImage.file)) loadImage.file.delete();
|
||||
}
|
||||
}
|
||||
String oldurl = selectedImage.imageUrl;
|
||||
selectedImage.followPageFormLoad(dir, loadinfo);
|
||||
selectedImage.load(host);
|
||||
LoadImage.save(selectedImage, host);
|
||||
new GuiRunnable<Object>() {
|
||||
public Object runSave() {
|
||||
pd.setValue(1);
|
||||
@ -647,7 +658,7 @@ public class LoadCaptchas {
|
||||
}.waitForEDT();
|
||||
if (oldurl.equals(selectedImage.toString())) {
|
||||
for (int k = 1; k < loadinfo.menge - 1; k++) {
|
||||
selectedImage.load(dir);
|
||||
selectedImage.directCaptchaLoad(dir);
|
||||
final int d = k;
|
||||
new GuiRunnable<Object>() {
|
||||
public Object runSave() {
|
||||
@ -658,7 +669,7 @@ public class LoadCaptchas {
|
||||
}
|
||||
} else {
|
||||
for (int k = 1; k < loadinfo.menge - 1; k++) {
|
||||
selectedImage.followPageFormLoad(dir, loadinfo);
|
||||
selectedImage.load(host);
|
||||
final int d = k;
|
||||
new GuiRunnable<Object>() {
|
||||
public Object runSave() {
|
||||
@ -692,154 +703,5 @@ public class LoadCaptchas {
|
||||
}.waitForEDT();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Diese klasse speichert Bildinformationen wie die Form die verwendet wurde und
|
||||
* die Bildposition
|
||||
*
|
||||
* @author dwd
|
||||
*
|
||||
*/
|
||||
class LoadImage {
|
||||
/**
|
||||
* ParentUrl
|
||||
*/
|
||||
public int followUrl = -1;
|
||||
/**
|
||||
* Bildadresse
|
||||
*/
|
||||
public String imageUrl;
|
||||
/**
|
||||
* Formposition -1 == keiner Form folgen
|
||||
*/
|
||||
public int form = -1;
|
||||
/**
|
||||
* Bildposition
|
||||
*/
|
||||
public int location = 0;
|
||||
/**
|
||||
* Browser mit dem das Bild runtergeladen wurde
|
||||
*/
|
||||
public Browser br;
|
||||
/**
|
||||
* datei in dem das Bild nach dem laden gespeichert wurde
|
||||
*/
|
||||
public File file;
|
||||
/**
|
||||
* zwischenspeicher für den DateiType
|
||||
*/
|
||||
private String fileType = null;
|
||||
|
||||
public LoadImage() {
|
||||
}
|
||||
|
||||
public LoadImage(String imageUrl, Browser br) {
|
||||
this.imageUrl = imageUrl;
|
||||
this.br = br.cloneBrowser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj != null && obj instanceof LoadImage) {
|
||||
String url = ((LoadImage) obj).imageUrl;
|
||||
if (imageUrl == url) return true;
|
||||
if (url == null) return false;
|
||||
return url.equals(imageUrl);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* läd das Bild direkt in den vorgegebenen Ordner
|
||||
*
|
||||
* @param destination
|
||||
*/
|
||||
public void load(String destination) {
|
||||
file = new File(destination, System.currentTimeMillis() + getFileType());
|
||||
try {
|
||||
br.getDownload(file, imageUrl);
|
||||
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ruft die Seite erneut auf und folgt den Forms um dann am ende das Bild zu
|
||||
* laden
|
||||
*
|
||||
* @param destination
|
||||
* @param loadInfo
|
||||
* @throws Exception
|
||||
*/
|
||||
public void followPageFormLoad(String destination, LoadInfo loadInfo) throws Exception {
|
||||
br.clearCookies(loadInfo.link);
|
||||
br.getPage(loadInfo.link);
|
||||
if (followUrl != -1) {
|
||||
String[] links = HTMLParser.getHttpLinks(br.toString(), br.getURL());
|
||||
br.getPage(links[followUrl]);
|
||||
}
|
||||
|
||||
if (form != -1) {
|
||||
br.submitForm(LoadCaptchas.getForms(br)[form]);
|
||||
}
|
||||
imageUrl = LoadCaptchas.getImages(br)[location];
|
||||
load(destination);
|
||||
}
|
||||
|
||||
public void setFileType(String fileType) {
|
||||
this.fileType = fileType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dateitype eines Bildes .jpg wenn er nicht erkannt wird
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getFileType() {
|
||||
if (fileType != null) return fileType;
|
||||
fileType = ".jpg";
|
||||
if (imageUrl.toLowerCase().contains("\\.png"))
|
||||
fileType = ".png";
|
||||
else if (imageUrl.toLowerCase().contains("\\.png"))
|
||||
fileType = ".gif";
|
||||
else {
|
||||
try {
|
||||
br.getPage(imageUrl);
|
||||
String ct2 = br.getHttpConnection().getContentType().toLowerCase();
|
||||
if (ct2 != null && ct2.contains("image")) {
|
||||
if (ct2.equals("image/jpeg"))
|
||||
fileType = ".jpg";
|
||||
else {
|
||||
fileType = ct2.replaceFirst("image/", ".");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
}
|
||||
return fileType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
public String toLowerCase() {
|
||||
return toString().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
class LoadInfo {
|
||||
boolean followLinks = false;
|
||||
|
||||
public String link;
|
||||
public int menge = 100;
|
||||
|
||||
public LoadInfo(String link, int menge) {
|
||||
this.link = link;
|
||||
this.menge = menge;
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package jd.captcha.easy;
|
||||
package jd.captcha.easy.load;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
import jd.gui.userio.DummyFrame;
|
243
src/jd/captcha/easy/load/LoadImage.java
Normal file
@ -0,0 +1,243 @@
|
||||
package jd.captcha.easy.load;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import jd.nutils.io.JDIO;
|
||||
|
||||
import jd.utils.JDUtilities;
|
||||
|
||||
import jd.http.Browser;
|
||||
import jd.parser.html.HTMLParser;
|
||||
|
||||
/**
|
||||
* Diese klasse speichert Bildinformationen wie die Form die verwendet wurde und
|
||||
* die Bildposition
|
||||
*
|
||||
* @author dwd
|
||||
*
|
||||
*/
|
||||
public class LoadImage {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adresse die als erstes geladen wird
|
||||
*/
|
||||
public String baseUrl;
|
||||
/**
|
||||
* followUrl unterurl die verwendet werden soll
|
||||
*/
|
||||
protected int followUrl = -1;
|
||||
/**
|
||||
* Bildadresse
|
||||
*/
|
||||
protected transient String imageUrl;
|
||||
/**
|
||||
* Formposition -1 == keiner Form folgen
|
||||
*/
|
||||
protected int form = -1;
|
||||
/**
|
||||
* zwischenspeicher für den DateiType
|
||||
*/
|
||||
protected String fileType = null;
|
||||
/**
|
||||
* Bildposition
|
||||
*/
|
||||
protected int location = 0;
|
||||
/**
|
||||
* Browser mit dem das Bild runtergeladen wurde
|
||||
*/
|
||||
public transient Browser br;
|
||||
/**
|
||||
* datei in dem das Bild nach dem laden gespeichert wurde
|
||||
*/
|
||||
protected transient File file;
|
||||
public transient boolean clearCookies = true;
|
||||
|
||||
public LoadImage(String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
public LoadImage() {
|
||||
this.br = new Browser();
|
||||
}
|
||||
|
||||
public LoadImage(LoadInfo loadInfo) {
|
||||
this.baseUrl = loadInfo.link;
|
||||
this.br = new Browser();
|
||||
}
|
||||
|
||||
public LoadImage(LoadInfo loadInfo, String imageUrl, Browser br) {
|
||||
this.baseUrl = loadInfo.link;
|
||||
this.imageUrl = imageUrl;
|
||||
this.br = br.cloneBrowser();
|
||||
}
|
||||
|
||||
public int getFollowUrl() {
|
||||
return followUrl;
|
||||
}
|
||||
|
||||
public void setFollowUrl(int followUrl) {
|
||||
this.followUrl = followUrl;
|
||||
}
|
||||
|
||||
public int getForm() {
|
||||
return form;
|
||||
}
|
||||
|
||||
public void setForm(int form) {
|
||||
this.form = form;
|
||||
}
|
||||
|
||||
public int getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(int location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getBaseUrl() {
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
public void setBaseUrl(String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj != null && obj instanceof LoadImage) {
|
||||
String url = ((LoadImage) obj).imageUrl;
|
||||
if (imageUrl == url) return true;
|
||||
if (url == null) return false;
|
||||
return url.equals(imageUrl);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* läd das Bild direkt in den vorgegebenen Ordner
|
||||
*
|
||||
* @param destination
|
||||
*/
|
||||
public void directCaptchaLoad(String destination) {
|
||||
file = new File(destination, System.currentTimeMillis() + getFileType());
|
||||
try {
|
||||
br.getDownload(file, imageUrl);
|
||||
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ruft die Seite erneut auf und folgt den Forms um dann am ende das Bild zu
|
||||
* laden
|
||||
*
|
||||
* @param host
|
||||
* @param loadInfo
|
||||
* @throws Exception
|
||||
*/
|
||||
public LoadImage load(String host) throws Exception {
|
||||
if (host == null) host = new URI(baseUrl).getHost();
|
||||
String destination = JDUtilities.getJDHomeDirectoryFromEnvironment().getAbsolutePath() + "/captchas/" + host + "/";
|
||||
new File(destination).mkdir();
|
||||
br.clearCookies(baseUrl);
|
||||
br.getPage(baseUrl);
|
||||
if (followUrl != -1) {
|
||||
String[] links = HTMLParser.getHttpLinks(br.toString(), br.getURL());
|
||||
br.getPage(links[followUrl]);
|
||||
}
|
||||
|
||||
if (form != -1) {
|
||||
br.submitForm(LoadCaptchas.getForms(br)[form]);
|
||||
}
|
||||
imageUrl = LoadCaptchas.getImages(br)[location];
|
||||
directCaptchaLoad(destination);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setFileType(String fileType) {
|
||||
this.fileType = fileType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dateitype eines Bildes .jpg wenn er nicht erkannt wird
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getFileType() {
|
||||
if (fileType != null) return fileType;
|
||||
if(imageUrl==null) return ".jpg";
|
||||
fileType = ".jpg";
|
||||
if (imageUrl.toLowerCase().contains("\\.png"))
|
||||
fileType = ".png";
|
||||
else if (imageUrl.toLowerCase().contains("\\.png"))
|
||||
fileType = ".gif";
|
||||
else {
|
||||
try {
|
||||
br.getPage(imageUrl);
|
||||
String ct2 = br.getHttpConnection().getContentType().toLowerCase();
|
||||
if (ct2 != null && ct2.contains("image")) {
|
||||
if (ct2.equals("image/jpeg"))
|
||||
fileType = ".jpg";
|
||||
else {
|
||||
fileType = ct2.replaceFirst("image/", ".");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
}
|
||||
return fileType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
public String toLowerCase() {
|
||||
return toString().toLowerCase();
|
||||
}
|
||||
/**
|
||||
* läd einen Vector<CPoint> aus eine XML Datei (methodedir/CPoints.xml)
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public static LoadImage loadFile(File file) {
|
||||
if (file.exists()) { return (LoadImage) JDIO.loadObject(null, file, true); }
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* läd ein LoadImage aus eine XML Datei (methodedir/CPoints.xml)
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public static LoadImage loadFile(String host) {
|
||||
File file = new File(JDUtilities.getJDHomeDirectoryFromEnvironment() + "/" + JDUtilities.getJACMethodsDirectory() + host + "/LoadImage.xml");
|
||||
return loadFile(file);
|
||||
}
|
||||
/**
|
||||
* Speichert ein LoadImage in eine XML Datei
|
||||
*
|
||||
* @param cPoints
|
||||
* @param file
|
||||
*/
|
||||
public static void save(LoadImage li, File file) {
|
||||
file.getParentFile().mkdirs();
|
||||
System.out.println("LoadImage has beens saved under: "+file);
|
||||
JDIO.saveObject(null, li, file, null, null, true);
|
||||
}
|
||||
/**
|
||||
* Speichert ein LoadImage in eine XML Datei (methodedir/LoadImage.xml)
|
||||
*
|
||||
* @param cPoints
|
||||
* @param file
|
||||
*/
|
||||
public static void save(LoadImage selectedImage, String host) {
|
||||
File file = new File(JDUtilities.getJDHomeDirectoryFromEnvironment() + "/" + JDUtilities.getJACMethodsDirectory() + host + "/LoadImage.xml");
|
||||
save(selectedImage,file);
|
||||
}
|
||||
}
|
13
src/jd/captcha/easy/load/LoadInfo.java
Normal file
@ -0,0 +1,13 @@
|
||||
package jd.captcha.easy.load;
|
||||
|
||||
public class LoadInfo {
|
||||
boolean followLinks = false;
|
||||
|
||||
public String link;
|
||||
public int menge = 100;
|
||||
|
||||
public LoadInfo(String link, int menge) {
|
||||
this.link = link;
|
||||
this.menge = menge;
|
||||
}
|
||||
}
|
@ -78,7 +78,7 @@ public class PixelObject implements Comparable<PixelObject> {
|
||||
* captcha als owner. Über owner kann auf den Parameter Dump zugegriffen
|
||||
* werden
|
||||
*/
|
||||
private PixelGrid owner;
|
||||
public PixelGrid owner;
|
||||
|
||||
/**
|
||||
* Als sicher angenommener Farb durchschnitt
|
||||
@ -559,7 +559,27 @@ public class PixelObject implements Comparable<PixelObject> {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public PixelObject[] horizintalSplitAt(int yposition) {
|
||||
PixelObject[] ret = new PixelObject[2];
|
||||
for (int i = 0; i < ret.length; i++) {
|
||||
ret[i] = new PixelObject(owner);
|
||||
}
|
||||
for (int i = 0; i < getSize(); i++) {
|
||||
int[] akt = elementAt(i);
|
||||
boolean b = true;
|
||||
for (int y = 0; y < 2; y++) {
|
||||
if (akt[1] >= yMin + y * yposition && akt[1] <= yMin + (y + 1) * yposition) {
|
||||
ret[y].add(akt[0], akt[1], saveAvg);
|
||||
b = false;
|
||||
}
|
||||
}
|
||||
if (b) {
|
||||
ret[1].add(akt[0], akt[1], saveAvg);
|
||||
}
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public PixelObject[] splitAt(int position) {
|
||||
PixelObject[] ret = new PixelObject[2];
|
||||
for (int i = 0; i < ret.length; i++) {
|
||||
@ -595,7 +615,6 @@ public class PixelObject implements Comparable<PixelObject> {
|
||||
*/
|
||||
public Letter toColoredLetter(int backgroundcolor,PixelGrid owner ) {
|
||||
Letter l = new Letter(getWidth(), getHeight());
|
||||
l.setOwner(owner.owner);
|
||||
l.setGrid(getGrid(backgroundcolor, owner));
|
||||
l.setElementPixel(getSize());
|
||||
l.setLocation(new int[] { getXMin(), getYMin() });
|
||||
@ -649,7 +668,6 @@ public class PixelObject implements Comparable<PixelObject> {
|
||||
|
||||
}
|
||||
Letter l = owner.createLetter();
|
||||
l.setOwner(owner.owner);
|
||||
l.setElementPixel(getSize());
|
||||
l.setLocation(new int[] { getXMin(), getYMin() });
|
||||
l.setGrid(ret);
|
||||
|
185
src/jd/captcha/specials/ProtectItOrg.java
Normal file
@ -0,0 +1,185 @@
|
||||
package jd.captcha.specials;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Vector;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import jd.captcha.JAntiCaptcha;
|
||||
|
||||
import jd.captcha.ColorLetterComperator;
|
||||
import jd.nutils.JDImage;
|
||||
import jd.captcha.LetterComperator;
|
||||
import jd.captcha.pixelgrid.PixelGrid;
|
||||
import jd.captcha.pixelobject.PixelObject;
|
||||
import jd.captcha.easy.BackGroundImageManager;
|
||||
import jd.captcha.pixelgrid.Captcha;
|
||||
import jd.captcha.pixelgrid.Letter;
|
||||
|
||||
public class ProtectItOrg {
|
||||
static ArrayList<PixelObject> getObjects(PixelGrid grid, int neighbourradius) {
|
||||
ArrayList<PixelObject> ret = new ArrayList<PixelObject>();
|
||||
ArrayList<PixelObject> merge;
|
||||
for (int x = 0; x < grid.getWidth(); x++) {
|
||||
for (int y = 0; y < grid.getHeight(); y++) {
|
||||
if (grid.getGrid()[x][y] == -3151923) continue;
|
||||
|
||||
PixelObject n = new PixelObject(grid);
|
||||
n.add(x, y, grid.getGrid()[x][y]);
|
||||
|
||||
merge = new ArrayList<PixelObject>();
|
||||
for (PixelObject o : ret) {
|
||||
if (o.isTouching(x, y, true, neighbourradius, neighbourradius)) {
|
||||
merge.add(o);
|
||||
}
|
||||
}
|
||||
if (merge.size() == 0) {
|
||||
ret.add(n);
|
||||
} else if (merge.size() == 1) {
|
||||
merge.get(0).add(n);
|
||||
} else {
|
||||
for (PixelObject po : merge) {
|
||||
ret.remove(po);
|
||||
n.add(po);
|
||||
}
|
||||
ret.add(n);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static void loadImagesIfNotExists(String code, Captcha captcha) {
|
||||
if (!captcha.owner.getResourceFile("images/r/" + code + ".png").exists()) {
|
||||
captcha.reset();
|
||||
BackGroundImageManager bgit = new BackGroundImageManager(captcha);
|
||||
bgit.clearCaptchaAll();
|
||||
captcha.crop(0, 0, 0, 10);
|
||||
ArrayList<PixelObject> obj = getObjects(captcha, 7);
|
||||
|
||||
for (PixelObject pixelObject : obj) {
|
||||
Image img = pixelObject.toColoredLetter().getImage();
|
||||
File retf = captcha.owner.getResourceFile("images/" + code + System.currentTimeMillis() + ".png");
|
||||
try {
|
||||
ImageIO.write((RenderedImage) img, "png", retf);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static Letter[] getLetters(Captcha captcha) throws Exception {
|
||||
captcha.crop(257, 140, 0, 0);
|
||||
ArrayList<Letter> let = new ArrayList<Letter>();
|
||||
Vector<PixelObject> objs = captcha.getObjects(0.7, 0.7);
|
||||
// EasyCaptcha.mergeObjectsBasic(objs, captcha, 3);
|
||||
Collections.sort(objs);
|
||||
for (PixelObject pixelObject : objs) {
|
||||
if (pixelObject.getArea() > 3) let.add(pixelObject.toLetter());
|
||||
}
|
||||
int c = 0;
|
||||
for (ListIterator<Letter> iterator = let.listIterator(let.size()); iterator.hasPrevious() && c++ < 10;) {
|
||||
iterator.previous();
|
||||
iterator.remove();
|
||||
}
|
||||
Letter[] lets = let.toArray(new Letter[] {});
|
||||
String code = "";
|
||||
for (Letter letter : lets) {
|
||||
LetterComperator r = captcha.owner.getLetter(letter);
|
||||
code += r.getDecodedValue();
|
||||
letter.detected = r;
|
||||
}
|
||||
File imageFile = captcha.owner.getResourceFile("images/" + code + ".png");
|
||||
if (imageFile.exists()) {
|
||||
captcha.reset();
|
||||
Captcha pixToFind = captcha.owner.createCaptcha(JDImage.getImage(imageFile));
|
||||
Letter l = captcha.createLetter();
|
||||
l.setGrid(pixToFind.grid);
|
||||
|
||||
BackGroundImageManager bgit = new BackGroundImageManager(captcha);
|
||||
bgit.clearCaptchaAll();
|
||||
captcha.crop(0, 0, 0, 10);
|
||||
ArrayList<PixelObject> obj = getObjects(captcha, 3);
|
||||
|
||||
ColorLetterComperator mainCLC = new ColorLetterComperator(l, l);
|
||||
double bestVal = 10000000.0;
|
||||
Letter bestLetter = null;
|
||||
for (PixelObject pixelObject : obj) {
|
||||
if (pixelObject.getWidth() > 63 || pixelObject.getHeight() > 63) {
|
||||
PixelObject[] objb = pixelObject.splitAt(62);
|
||||
for (PixelObject pixelObject2 : objb) {
|
||||
if(pixelObject.getHeight() > 63)
|
||||
{
|
||||
PixelObject[] objb2 = pixelObject2.horizintalSplitAt(62);
|
||||
for (PixelObject pixelObject3 : objb2) {
|
||||
Letter b = pixelObject3.toColoredLetter();
|
||||
mainCLC.setLetterB(b);
|
||||
double val = mainCLC.run();
|
||||
if (val < bestVal) {
|
||||
bestLetter = b;
|
||||
bestVal = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Letter b = pixelObject2.toColoredLetter();
|
||||
mainCLC.setLetterB(b);
|
||||
double val = mainCLC.run();
|
||||
|
||||
if (val < bestVal) {
|
||||
bestLetter = b;
|
||||
bestVal = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Letter b = pixelObject.toColoredLetter();
|
||||
mainCLC.setLetterB(b);
|
||||
double val = mainCLC.run();
|
||||
|
||||
if (val < bestVal) {
|
||||
bestLetter = b;
|
||||
bestVal = val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
int x = bestLetter.getLocation()[0] + (bestLetter.getWidth() / 2);
|
||||
int y = bestLetter.getLocation()[1] + (bestLetter.getHeight() / 2);
|
||||
char[] tx = (x + ":" + y).toCharArray();
|
||||
Letter[] ret = new Letter[tx.length];
|
||||
for (int i = 0; i < tx.length; i++) {
|
||||
Letter re = new Letter();
|
||||
re.setDecodedValue(""+tx[i]);
|
||||
LetterComperator let1 = new LetterComperator(re, re);
|
||||
let1.setValityPercent(0);
|
||||
re.detected=let1;
|
||||
ret[i]=re;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Letter[] let = new Letter[obj.size()];
|
||||
// for (int j = 0; j < let.length; j++) {
|
||||
// let[j]=toLetter(obj.get(j), captcha);
|
||||
// BasicWindow.showImage(obj.get(j).toLetter().getFullImage());
|
||||
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
public static Letter[] letterFilter(Letter[] org, JAntiCaptcha jac) {
|
||||
return org;
|
||||
}
|
||||
}
|
@ -59,7 +59,7 @@ public class SourceParser {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
parse("system.update.error.message");
|
||||
parse("protect");
|
||||
}
|
||||
|
||||
}
|
||||
|