<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000099">
Hi Robert,<br>
<br>
thanks for the tip. Works like a charm!<br>
Might be interesting to add it to the manual.<br>
<br>
For info, the class that needs to be specified in <font size="2">resolvers.addImageComparison
</font>must match with the one used for registering the
ItemResolver.<br>
<br>
Let's remain to implement this resolver ;-)<br>
<br>
Cheers,<br>
Denis.<br>
<br>
<br>
On 14/09/2010 5:23 PM, Robert Lahmer, QFS support wrote:
<blockquote
cite="mid:C062DF61565C8BCA4D51F51B@D674CC06F27B528C319A4859"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<meta name="Generator" content="MS Exchange Server version
08.02.0231.000">
<title>Re: [QF-Test] How to implement a custom ImageComparator</title>
<!-- Converted from text/plain format -->
<br>
<p><font size="2">Hello Denis,<br>
<br>
I remember having had an RMI problem with the ImageComparator
too. I also<br>
found a workaround, but I'm not sure whether it applies to
your situation<br>
where you try to use it inside a custom checker.<br>
<br>
However, instead of using the ImageComparator interface, it's
probably<br>
easier to implement an ImageComparison resolver like so:<br>
<br>
<br>
def compareImages(expected, actual, width, height):<br>
# if comparison is not ok:<br>
# return "Bad image"<br>
return None # ok<br>
<br>
resolvers.addImageComparison("myImageComp", compareImages,<br>
"mypck.MyImageComponent")<br>
<br>
<br>
If you want to go back to the default image comparison for
components of<br>
class "MyImageComponent", just remove the resolver in another
'SUT script':<br>
<br>
<br>
resolvers.removeResolver("myImageComp")<br>
<br>
<br>
Best regards,<br>
Robert<br>
<br>
<br>
<br>
--On Montag, September 13, 2010 18:31:41 +1000 "Gauthier,
Denis"<br>
<a class="moz-txt-link-rfc2396E" href="mailto:Denis.Gauthier@thalesgroup.com.au"><Denis.Gauthier@thalesgroup.com.au></a> wrote:<br>
<br>
> Hi everyone,<br>
><br>
> did anyone ever tried (and managed) to implement a custom
ImageComparator?<br>
><br>
> I am trying to follow the 'Image API Extensions' guide
but without much<br>
> success.<br>
><br>
> Basically in a custom Checker interface (in Python) I do
the following:<br>
><br>
> ......<br>
> ......<br>
> def getCheckData(self, canvas, item, checkType):<br>
> if checkType.getDataType() == CheckDataType.IMAGE<br>
> iw = ImageWrapper(None)<br>
> image = iw.grabScreenshot(x, y, w, h) # x,y,w,h
are defined at<br>
> that point image.setComparator(
MyImageComparator() )<br>
> return ImageCheckData(checkType.getIdentifier(),
image,<br>
> 0,0,0,0,w,h) return None<br>
><br>
> class SymbolComparator(ImageComparator):<br>
> def equals(self, actual, expected):<br>
># Actual implementation to be done<br>
> return True<br>
><br>
><br>
> (I skipped all the import statements).<br>
><br>
> This code works well without the image.setComparator(
...) statement.<br>
> Setting this custom ImageComparator generates me an error
when recording<br>
> an 'Image Check' through QFTest. I have a huge exception
about the<br>
> SymbolComparator class that cannot be serialized.<br>
><br>
> I tried to write the same code in Java and to stick the
jar file in the<br>
> plugin/sut folder, same result. Making this class
implementing the<br>
> java.io.Serializable does not help either as this time
this is a RMI<br>
> exception that is thrown java.rmi.ServerException ==><br>
> ClassNotFoundException<br>
><br>
> Is there any further steps that are required? Does this
class need to be<br>
> copied somewhere else? Can't we just do it in pure
Python?<br>
> Is there any example available?<br>
><br>
> Thanks for your help as I really need to get my own image
comparison code<br>
> ....<br>
><br>
> Denis.<br>
><br>
><br>
><br>
>
DISCLAIMER:--------------------------------------------------------------<br>
> ------------- This e-mail transmission and any documents,
files and<br>
> previous e-mail messages attached to it are private and
confidential.<br>
> They may contain proprietary or copyright material or
information that is<br>
> subject to legal professional privilege. They are for the
use of the<br>
> intended recipient only. Any unauthorised viewing, use,
disclosure,<br>
> copying, alteration, storage or distribution of, or
reliance on, this<br>
> message is strictly prohibited. No part may be
reproduced, adapted or<br>
> transmitted without the written permission of the owner.
If you have<br>
> received this transmission in error, or are not an
authorised recipient,<br>
> please immediately notify the sender by return email,
delete this message<br>
> and all copies from your e-mail system, and destroy any
printed copies.<br>
> Receipt by anyone other than the intended recipient
should not be deemed a<br>
> waiver of any privilege or protection. Thales Australia
does not warrant<br>
> or represent that this e-mail or any documents, files and
previous e-mail<br>
> messages attached are error or virus free.<br>
>
-------------------------------------------------------------------------<br>
> -------------<br>
><br>
<br>
<br>
<br>
--<br>
QFS Support - Robert Lahmer<br>
Quality First Software GmbH <a
moz-do-not-send="true" href="http://www.qfs.de">http://www.qfs.de</a><br>
Tulpenstr. 41 Tel: +49 8171 38648-20<br>
DE-82538 Geretsried Fax: +49 8171 38648-16<br>
GF: Gregor Schmid, Karlheinz Kellerer HRB München 140833<br>
<br>
</font>
</p>
</blockquote>
DISCLAIMER:---------------------------------------------------------------------------
This e-mail transmission and any documents, files and previous e-mail messages
attached to it are private and confidential. They may contain proprietary or copyright
material or information that is subject to legal professional privilege. They are for
the use of the intended recipient only. Any unauthorised viewing, use, disclosure,
copying, alteration, storage or distribution of, or reliance on, this message is
strictly prohibited. No part may be reproduced, adapted or transmitted without the
written permission of the owner. If you have received this transmission in error, or
are not an authorised recipient, please immediately notify the sender by return email,
delete this message and all copies from your e-mail system, and destroy any printed
copies. Receipt by anyone other than the intended recipient should not be deemed a
waiver of any privilege or protection. Thales Australia does not warrant or represent
that this e-mail or any documents, files and previous e-mail messages attached are
error or virus free.
--------------------------------------------------------------------------------------
</body>
</html>