5 ms·
This is nitpicking. Well, maybe not. This code does not take a swirled image and solve it. It takes a set of images with various swirl levels and finds the on
by robomartin 14y ago
This is nitpicking. Well, maybe not.
This code does not take a swirled image and solve it. It takes a set of images with various swirl levels and finds the one with shortest sum of edge lengths.
The code does not do any un-swirling of the image. It also uses external libraries to convert to grayscale, apply the Sobel filter and the sum of edges.
I other words, it is far from breaking the swirled CAPTCHA in 23 lines of Python. If you had to write the un-swirling, gray-scaling, Sobel filtering and summation code in Python you'd be looking at a much larger pile-o-code.
The demo and the intent is good. I just wish the title didn't say "23 lines of". I don't think the article would have suffered at all if the title was "Breaking the MintEye image CAPTCHA with Python".
Again, the intent and what is being demonstrated are excellent. The title, in my not-so-humble opinion, is hugely misleading.
- chmod775 14y ago>it is far from breaking the swirled CAPTCHA in 23 lines of Python Except it does break the captcha in 23 lines. I don't get your point. Why would he need to do any 'un-swirling' in the first place? That's not the point of the captcha. The captcha provides you with multiple images and you have to pick the least swirled one - which is exactly what his code does. And you argue that because he did use external libraries it's not 23 lines of python. Of course it is. He had to write only 23 lines that make up the logic to break the captcha. If you'd argue that one would have to add any previous work (or lines) done by other people to the linecount of your own project, I could also argue that 'print("Hello")' is not one line of python, because it uses some standard python library, which in turn calls native code, that native code would make a few syscalls and at some point resulting in multiple hundred lines of compiled kernel C code being executed. So the linecount of his 23 lines python script would actually be: 23 lines of python + various libraries + the entire Linux kernel = roughly 20 million lines of code. Good job. And yes, that was nitpicking. And I'm angry for some reason.
- cidquick 14y agoWell put. The title is indeed completely factual! Including '23 lines' was just to let people know at first glance that the solution is simple. > If you had to write the un-swirling, gray-scaling, Sobel filtering and summation code in Python you'd be looking at a much larger pile-o-code I would also like to point out these are also all very simple operations, which would only take a few lines of Python/C/whatever to do. Python just happens to have a pre-written libraries to save reinventing the wheel.
- robomartin 14y ago> I would also like to point out these are also all very simple operations, which would only take a few lines of Python/C/whatever to do. Yikes! They are not. That's a lot of code. I've done a ton of image processing work in both hardware (FPGA) and software (various languages). Swirling, gray-scaling, Sobel filtering and summation collectively are far from "a few lines of Python/C/whatever to do" > Python just happens to have a pre-written libraries to save reinventing the wheel That's not true. OpenCV is NOT a Python library, it's nearly 100% C++ as far as I can tell: https://github.com/Itseez/opencv https://github.com/Itseez/opencv That was, in many ways, my point. This is not a solution in 23 lines of Python. Go install Python from Python.org --and NOTHING ELSE-- and solve the problem. Let's see how many lines of Python it takes. There's nothing wrong with the intent of the author in terms of showing how one can break these CAPTCHA's using edge-length evaluation. I never put any thought into this myself so, yes, I learned something of value from his post. I just wish the title was more genuine, that's all.
- cidquick 14y agoMy turn to nitpick! RGB to grayscale: V = r x g x b/3 (one line). The Sobel operation is at most 4 nested loops (really only 3) for a total of ~7 lines of code, depending on how you like your white space. Fold the summation into your Sobel function without requiring another line. The most complicated thing used from the OpenCV library (which I'm well aware is C++!) is JPEG decoding. OK, I'm avoiding swirling, but then it isn't needed to solve the CAPTCHA anyway.
- robomartin 14y agoShow me working code and then we can talk. :) Oh, BTW, "V = r x g x b/3" is incorrect. This is not you convert a color image to a grayscale image.
- deleted 14y ago[deleted]
- 14y ago
- floody-berry 14y agoIf you aren't going to have a cut off point for what is considered solving the problem and what is considered ancillary, then you can define new languages where a zero byte input stands for whatever solution you want, simultaneously one-upping everyone and contributing nothing to the conversation.
- jlgreco 14y agoUnless the test of "human-ness" is the ability to drag a slider, or whoever it is that you interact with the captcha, picking the least swirled of a set of images is solving the captcha because that is the test of human-ness. This seems fairly cut and dry to me.
- robomartin 14y agoNo need to be angry. None of this is going to remove food from your table or affect your life in any way whatsoever. Take it easy. I am just opening the topic for conversation. We can discuss things without pulling out semi-automatic weapons, right? When someone publishes code and says something like "solved <problem> in <n lines> of <pick your language>" there generally is an implied "my language is better than yours" subliminal message that, for some strange reason, is based on line count. Let's not debate the merit of line count as a measure of how good a language may or may not be. If we are going to go there I'll write the same solution in APL and we'll start counting characters instead. Again, line or character count, in my opinion, is not a measure of the "superiority" of a language. The 28 line solution is not pure Python. How do we define pure Python. Let's just say that "solved <problem> in <n lines> of Python" to me means that you download and install Python: http://www.python.org/download/releases/2.7.3/ http://www.python.org/download/releases/2.7.3/ Install nothing else whatsoever and write code that solves <problem>. OpenCV, which is what the author used for a couple of aspects of this code, is an extensive (and really cool) C++ library that is being accessed from Python. Here's the source: https://github.com/Itseez/opencv https://github.com/Itseez/opencv I'll leave it up to the reader to find the source for the Sobel method. A much more honest title could have included something like "solving <problem> with <n> lines of Python using OpenCV". As I said before, the intent of the article and what is being demonstrated are good, no, great. I just wish the title was a little more reflective of reality. That's all. No need to get worked-up. This is not that serious of an issue. Just a comment.
- stch 14y agoActually, that's not entirely reflective of reality. You would have to access www.python.org in order to download python, so you'd have to write some sort of TCP/IP handler to connect to that interface...actually let me back up, you first would have to solder together a few million transistors to create a CPU before you could do that. You're making it seem way easier than it actually is, please don't go exaggerating the truth so blatantly.
- readme 14y agoSomeone has disagreed with you -- which you anticipated would happen. Therefore he must be angry? I agree with him. If it's wrapped up in a library and it's distributed by a package manager then it doesn't count towards the total SLOC of your project.
- mikeash 14y agoAnd if you had to write the OS it runs on you'd have a really huge "pile-o-code". What's your point?
- robomartin 14y ago> What's your point? Simple. To go along the lines of your example: Headline: "Microsoft Word written in 50 lines of Python". Reality: The fifty lines of Python do nothing more than call a set of Microsoft libraries written in C and C++ that, well, result in MS Word. Did the author really write MS Word in 50 lines of Python? Of course not. It would be absolutely insane to even suggest the idea that this could even approach a valid metric. Nope, the author simply made use of external non-Python libraries that are the results of probably hundreds of thousands of lines of code and many man-years of work. He does not, for even a microsecond, get to claim that he wrote MS Word in 50 lines of Python. That's my point. Is it a little bit clearer now?
- mikeash 14y agoI would be interested to know that there are libraries that allow a person to write MS Word with only 50 additional lines of Python. Again, unless you write the entire stack from the bottom up, you're always depending on vast amounts of code you didn't write. So what's the difference?
- robomartin 14y agoOf course that was an exaggeration, a tool to simply drive the point home. It would be impossible to actually do what I suggested. The point, which for some reason you are not willing to concede, is that if you are going to claim that you solved a problem with x lines of programming language z the line count needs to be real. You can't use something like a library with 10,000 lines of C++ code to then claim that you solved a problem with two lines of Python (or whatever): import huge_code_base print huge_code_base.solve() It really is that simple. If you don't see it this way, well, that's fine. Let's leave it be.