//UPGRADE_NOTE: Final was removed from the declaration of 'image '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
privateBitMatriximage;
privateResultPointCallbackresultPointCallback;
publicDetector(BitMatriximage)
{
this.image=image;
}
/// <summary> <p>Detects a QR Code in an image, simply.</p>
///
/// </summary>
/// <returns> {@link DetectorResult} encapsulating results of detecting a QR Code
/// </returns>
/// <throws> ReaderException if no QR Code can be found </throws>
publicvirtualDetectorResultdetect()
{
returndetect(null);
}
/// <summary> <p>Detects a QR Code in an image, simply.</p>
///
/// </summary>
/// <param name="hints">optional hints to detector
/// </param>
/// <returns> {@link DetectorResult} encapsulating results of detecting a QR Code
/// </returns>
/// <throws> ReaderException if no QR Code can be found </throws>
// Estimate that alignment pattern is closer by 3 modules
// from "bottom right" to known top left location
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
// Kind of arbitrary -- expand search radius before giving up
for(inti=4;i<=16;i<<=1)
{
try
{
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
// Now count other way -- don't run off image though of course
floatscale=1.0f;
intotherToX=fromX-(toX-fromX);
if(otherToX<0)
{
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
scale=(float)fromX/(float)(fromX-otherToX);
otherToX=0;
}
elseif(otherToX>=image.Width)
{
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
intotherToY=(int)(fromY-(toY-fromY)*scale);
scale=1.0f;
if(otherToY<0)
{
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
scale=(float)fromY/(float)(fromY-otherToY);
otherToY=0;
}
elseif(otherToY>=image.Height)
{
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
intstate=0;// In black pixels, looking for white, first or second time
for(intx=fromX,y=fromY;x!=toX;x+=xstep)
{
intrealX=steep?y:x;
intrealY=steep?x:y;
if(state==1)
{
// In white pixels, looking for black
if(image.get_Renamed(realX,realY))
{
state++;
}
}
else
{
if(!image.get_Renamed(realX,realY))
{
state++;
}
}
if(state==3)
{
// Found black, white, black, and stumbled back onto white; done
intdiffX=x-fromX;
intdiffY=y-fromY;
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
// Look for an alignment pattern (3 modules in size) around where it
// should be
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
/// <summary> Ends up being a bit faster than Math.round(). This merely rounds its argument to the nearest int,
/// where x.5 rounds up.
/// </summary>
privatestaticintround(floatd)
{
//UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"