Exemplo n.º 1
1
int main(int argc, char ** argv)
{
    // Global errno reset to properly parse errors from fopen() function call
    errno = 0;
    // User specified passphrase
    char password[BUFSIZ];
    // Length of the password
    int length = 0;
    // Randomly generated key
    char key[BUFSIZ];
    // Bitmask used to encrypt file
    char mask[BUFSIZ];
    // Set to user-specified file
    FILE * file = 0;
    
    // Check if a file is specified
    if(--argc != 1) {
       
        (void)fprintf(stderr, USAGE);
        return EXIT_FAILURE;
    }

    file = fopen(argv[1], READ_MODE);

    // Check if file is valid
    if(file == NULL) {

        if(errno == EACCES) {

            // User does not have permission to read/write file, print error
            (void)fprintf(stderr, NO_ACCESS);
            return EXIT_FAILURE;
        } 
        else {

            // File itself is invalid, print error
            (void)fprintf(stderr, FILE_INVALID); 
            return EXIT_FAILURE;
        }

    } 
    else {

        (void)printf(PASS_PROMPT); 
        (void)scanf("%s", password);

        // Check if password is at least 8 characters long
        if(!parsePassword(password, &length)) {

            (void)fprintf(stderr, PASS_SHORT);
            return EXIT_FAILURE;
        }

        // Randomly generate the key based on password length
        (void)generateKey(length, key);
        (void)generateMask(key, password, mask, length);
    }

    return EXIT_SUCCESS;    
}
Exemplo n.º 2
0
void loadTextData(const char *pFileName, byte *pDestinationBuffer) {
	Common::File pFileHandle;
	uint16 entrySize;
	uint16 numEntry;
	uint16 i;
	byte *tempBuffer;
	uint16 dataSize;

	assert(pFileName);
	assert(pDestinationBuffer);

	pFileHandle.open(pFileName);

	assert(pFileHandle.isOpen());

	entrySize = pFileHandle.readUint16BE();
	numEntry = pFileHandle.readUint16BE();

	dataSize = numEntry * entrySize;
	pFileHandle.read(pDestinationBuffer, numEntry * entrySize);

	tempBuffer = pDestinationBuffer;

	if (gameType == Cine::GID_FW) {
		dataSize = dataSize / 0x4E;

		loadRelatedPalette(pFileName);

		for (i = 0; i < 0x4E; i++) {
			gfxConvertSpriteToRaw(textTable[i][0], tempBuffer, 16, 8);
			generateMask(textTable[i][0], textTable[i][1], 16 * 8, 0);
			tempBuffer += dataSize;
		}
	} else {
		for (i = 0; i < 90; i++) {
			gfxConvertSpriteToRaw(textTable[i][0], tempBuffer, 8, 8);
			generateMask(textTable[i][0], textTable[i][1], 8 * 8, 0);
			tempBuffer += 0x40;
		}
	}

	pFileHandle.close();
}
Exemplo n.º 3
0
  void init(Parameter *para) {
    generateMask(para);
    size_t initCount = this->initCount_.fetch_add(1);
    CHECK_EQ(initCount, 0UL) << "Currently the StaticPruningHook must invoke "
                                "in same ParamterUpdater";
    VLOG(3) << "Initialize Parameter " << para;
    SetDevice device(para->getDeviceId());

    auto &paraVec = para->getBuf(PARAMETER_VALUE);
    paraVec->dotMul(*maskVec_);
  }
Exemplo n.º 4
0
void Websocket::makeHeader(uint8_t *data, const uint64_t data_size, const uint64_t length,const uint16_t flags) {
    if(Websocket::reserve(length , flags) > data_size) {
        //todo throw exception
    }
    uint8_t header_size = 1;

    flags2header(data,flags);
    header_size += length2header(data,length);
    
    if( data[1] & 0x80) {
        generateMask(data + header_size);
        header_size += 4;
    }
}
Exemplo n.º 5
0
void SkScalerContext::getImage(const SkGlyph& origGlyph) {
    const SkGlyph*  glyph = &origGlyph;
    SkGlyph         tmpGlyph;

    if (fMaskFilter) {   // restore the prefilter bounds
        tmpGlyph.init(origGlyph.fID);

        // need the original bounds, sans our maskfilter
        SkMaskFilter* mf = fMaskFilter;
        fMaskFilter = NULL;             // temp disable
        this->getMetrics(&tmpGlyph);
        fMaskFilter = mf;               // restore

        tmpGlyph.fImage = origGlyph.fImage;

        // we need the prefilter bounds to be <= filter bounds
        SkASSERT(tmpGlyph.fWidth <= origGlyph.fWidth);
        SkASSERT(tmpGlyph.fHeight <= origGlyph.fHeight);
        glyph = &tmpGlyph;
    }

    if (fGenerateImageFromPath) {
        SkPath      devPath, fillPath;
        SkMatrix    fillToDevMatrix;
        SkMask      mask;

        this->internalGetPath(*glyph, &fillPath, &devPath, &fillToDevMatrix);
        glyph->toMask(&mask);

        if (fRasterizer) {
            mask.fFormat = SkMask::kA8_Format;
            sk_bzero(glyph->fImage, mask.computeImageSize());

            if (!fRasterizer->rasterize(fillPath, fillToDevMatrix, NULL,
                                        fMaskFilter, &mask,
                                        SkMask::kJustRenderImage_CreateMode)) {
                return;
            }
        } else {
            generateMask(mask, devPath);
        }
    } else {
        this->getGlyphContext(*glyph)->generateImage(*glyph);
    }

    if (fMaskFilter) {
        SkMask      srcM, dstM;
        SkMatrix    matrix;

        // the src glyph image shouldn't be 3D
        SkASSERT(SkMask::k3D_Format != glyph->fMaskFormat);
        glyph->toMask(&srcM);
        fRec.getMatrixFrom2x2(&matrix);

        if (fMaskFilter->filterMask(&dstM, srcM, matrix, NULL)) {
            int width = SkFastMin32(origGlyph.fWidth, dstM.fBounds.width());
            int height = SkFastMin32(origGlyph.fHeight, dstM.fBounds.height());
            int dstRB = origGlyph.rowBytes();
            int srcRB = dstM.fRowBytes;

            const uint8_t* src = (const uint8_t*)dstM.fImage;
            uint8_t* dst = (uint8_t*)origGlyph.fImage;

            if (SkMask::k3D_Format == dstM.fFormat) {
                // we have to copy 3 times as much
                height *= 3;
            }

            // clean out our glyph, since it may be larger than dstM
            //sk_bzero(dst, height * dstRB);

            while (--height >= 0) {
                memcpy(dst, src, width);
                src += srcRB;
                dst += dstRB;
            }
            SkMask::FreeImage(dstM.fImage);
        }
    }
}
Exemplo n.º 6
0
void convertImages(Arguments* args){
    char** mask = NULL;
    TwoPoints source, dest;
    FILE* eyeList;
    char line[ FILE_LINE_LENGTH ];
    char filename[MAX_FILENAME_LENGTH];
    char imagename[MAX_FILENAME_LENGTH];
    char suffix[MAX_FILENAME_LENGTH];
    int i;

    scaleArgs(args, args->scale);

    dest.x1 = args->eyeLx;
    dest.y1 = args->eyeLy;
    dest.x2 = args->eyeRx;
    dest.y2 = args->eyeRy;

    /* Prepare file suffix encoding preprocessing settings, blank if not requested */
    if (args->configSuffix) {
        sprintf(suffix,"_%s", imageSuffix(args)); }
    else {
        suffix[0] = '\0'; }	

    if(args->maskType == CL_YES){
        MESSAGE("Creating Mask.");
        mask = generateMask(args->sizeWidth, args->sizeHeight, args->ellipseX, args->ellipseY, args->ellipseA, args->ellipseB);
    }

    eyeList = fopen(args->eyeFile,"r");
    DEBUG_CHECK(eyeList,"Error opening eye coordinates file");

    for(i = 1;;i++){
        Image pgm;
        Image geo;
        Matrix transform;

        fgets(line, FILE_LINE_LENGTH, eyeList);
        if(feof(eyeList)) break;

        if(sscanf(line,"%s %lf %lf %lf %lf",filename, &(source.x1), &(source.y1), &(source.x2), &(source.y2)) != 5){
            printf("Error parsing line %d of eye coordinate file. Exiting...",i);
            exit(1);
        }

        /* shift the eye coordinates if neccessary */
        source.x1 += args->shiftX;
        source.y1 += args->shiftY;
        source.x2 += args->shiftX;
        source.y2 += args->shiftY;

        sprintf(imagename,"%s\\%s.pgm",args->inputDir,filename);

        MESSAGE1ARG("Processing image: %s",filename);

        pgm = readPGMImage(imagename);

        if(args->histType == HIST_PRE){
            DEBUG(1,"   Performing Pre Histogram Equalization.");
            histEqual(pgm,256);
        }

        if(args->preNormType == CL_YES){
            DEBUG(1,"   Performing Pre Pixel Normalization.");
            ZeroMeanOneStdDev(pgm);
        }

        if(args->preEdge){
            smoothImageEdge(pgm, args->preEdge);
        }

        if(args->geoType == CL_YES){
            DEBUG(1,"   Performing Geometric Normalization.");
            transform = generateTransform(&source,&dest,args->reflect);
            geo = transformImage(pgm,args->sizeWidth,args->sizeHeight,transform);
        }
        else{
            transform = makeIdentityMatrix(3);
            geo = transformImage(pgm,args->sizeWidth,args->sizeHeight,transform);
        }

        if(args->noise != 0.0){
            DEBUG(1,"   Adding Gausian Noise.");
            gaussianNoise(geo,args->noise);
        }


        if(args->histType == HIST_POST){
            DEBUG(1,"   Performing Post Histogram Equalization.");
            histEqualMask(geo,256, (const char**) mask);
        }

        if(args->nrmType == CL_YES){
            DEBUG(1,"   Performing final value normalization and Applying Mask.");
            ZeroMeanOneStdDevMasked(geo, (const char **) mask);
        }
        else{
            DEBUG(1,"   No Value Normalization. Just Applying Mask.");
            applyMask(geo, (const char **) mask);
        }

        if(args->postEdge){
            smoothImageEdge(geo, args->postEdge);
        }

        if(args->nrmDir){
            sprintf(imagename,"%s\\%s%s.nrm", args->nrmDir, filename, suffix);
            DEBUG_STRING(1,"   Saving nrm: %s",imagename);
            writeFeretImage(geo,imagename);
        }
        if(args->pgmDir){
            sprintf(imagename,"%s\\%s%s.pgm", args->pgmDir, filename, suffix);
            DEBUG_STRING(1,"   Saving pgm: %s",imagename);
            writePGMImage(geo,imagename,0);
        }
        if(args->sfiDir){
            sprintf(imagename,"%s\\%s%s.sfi", args->sfiDir, filename, suffix);
            DEBUG_STRING(1,"   Saving sfi: %s",imagename);
            writeRawImage(geo,imagename);
        }

        freeImage(geo);
        freeImage(pgm);
        freeMatrix(transform);
    }

    fclose(eyeList);

}
Exemplo n.º 7
0
/**
 * Draw one overlay
 * @param it Overlay info
 * @todo Add handling of type 22 overlays
 */
void OSRenderer::renderOverlay(const Common::List<overlay>::iterator &it) {
	int len, idx, width, height;
	ObjectStruct *obj;
	AnimData *sprite;
	byte *mask;
	byte color;

	switch (it->type) {
	// color sprite
	case 0:
		if (g_cine->_objectTable[it->objIdx].frame < 0) {
			break;
		}
		sprite = &g_cine->_animDataTable[g_cine->_objectTable[it->objIdx].frame];
		len = sprite->_realWidth * sprite->_height;
		mask = new byte[len];
		generateMask(sprite->data(), mask, len, g_cine->_objectTable[it->objIdx].part);
		remaskSprite(mask, it);
		drawMaskedSprite(g_cine->_objectTable[it->objIdx], mask);
		delete[] mask;
		break;

	// game message
	case 2:
		if (it->objIdx >= g_cine->_messageTable.size()) {
			return;
		}

		_messageLen += g_cine->_messageTable[it->objIdx].size();
		drawMessage(g_cine->_messageTable[it->objIdx].c_str(), it->x, it->y, it->width, it->color);
		if (it->color >= 0) { // This test isn't in Future Wars's implementation
			waitForPlayerClick = 1;
		}
		break;

	// action failure message
	case 3:
		idx = it->objIdx * 4 + g_cine->_rnd.getRandomNumber(3);
		len = strlen(failureMessages[idx]);
		_messageLen += len;
		width = 6 * len + 20;
		width = width > 300 ? 300 : width;

		// The used color here differs from Future Wars
		drawMessage(failureMessages[idx], (320 - width) / 2, 80, width, _messageBg);
		waitForPlayerClick = 1;
		break;

	// bitmap
	case 4:
		if (g_cine->_objectTable[it->objIdx].frame >= 0) {
			FWRenderer::renderOverlay(it);
		}
		break;

	// masked background
	case 20:
		assert(it->objIdx < NUM_MAX_OBJECT);
		var5 = it->x; // A global variable updated here!
		obj = &g_cine->_objectTable[it->objIdx];
		sprite = &g_cine->_animDataTable[obj->frame];

		if (obj->frame < 0 || it->x < 0 || it->x > 8 || !_bgTable[it->x].bg || sprite->_bpp != 1) {
			break;
		}

		maskBgOverlay(_bgTable[it->x].bg, sprite->data(), sprite->_realWidth, sprite->_height, _backBuffer, obj->x, obj->y);
		break;

	// FIXME: Implement correct drawing of type 21 overlays.
	// Type 21 overlays aren't just filled rectangles, I found their drawing routine
	// from Operation Stealth's drawSprite routine. So they're likely some kind of sprites
	// and it's just a coincidence that the oxygen meter during the first arcade sequence
	// works even somehow currently. I tried the original under DOSBox and the oxygen gauge
	// is a long red bar that gets shorter as the air runs out.
	case 21:
	// A filled rectangle:
	case 22:
		// TODO: Check it this implementation really works correctly (Some things might be wrong, needs testing).
		assert(it->objIdx < NUM_MAX_OBJECT);
		obj = &g_cine->_objectTable[it->objIdx];
		color = obj->part & 0x0F;
		width = obj->frame;
		height = obj->costume;
		drawPlainBox(obj->x, obj->y, width, height, color);
		debug(5, "renderOverlay: type=%d, x=%d, y=%d, width=%d, height=%d, color=%d",
			it->type, obj->x, obj->y, width, height, color);
		break;

	// something else
	default:
		FWRenderer::renderOverlay(it);
		break;
	}
}
Exemplo n.º 8
0
void SkScalerContext::getImage(const SkGlyph& origGlyph) {
    const SkGlyph*  glyph = &origGlyph;
    SkGlyph         tmpGlyph;

    // in case we need to call generateImage on a mask-format that is different
    // (i.e. larger) than what our caller allocated by looking at origGlyph.
    SkAutoMalloc tmpGlyphImageStorage;

    // If we are going to draw-from-path, then we cannot generate color, since
    // the path only makes a mask. This case should have been caught up in
    // generateMetrics().
    SkASSERT(!fGenerateImageFromPath ||
             SkMask::kARGB32_Format != origGlyph.fMaskFormat);

    if (fMaskFilter) {   // restore the prefilter bounds
        tmpGlyph.initGlyphIdFrom(origGlyph);

        // need the original bounds, sans our maskfilter
        SkMaskFilter* mf = fMaskFilter;
        fMaskFilter = nullptr;             // temp disable
        this->getMetrics(&tmpGlyph);
        fMaskFilter = mf;               // restore

        // we need the prefilter bounds to be <= filter bounds
        SkASSERT(tmpGlyph.fWidth <= origGlyph.fWidth);
        SkASSERT(tmpGlyph.fHeight <= origGlyph.fHeight);

        if (tmpGlyph.fMaskFormat == origGlyph.fMaskFormat) {
            tmpGlyph.fImage = origGlyph.fImage;
        } else {
            tmpGlyphImageStorage.reset(tmpGlyph.computeImageSize());
            tmpGlyph.fImage = tmpGlyphImageStorage.get();
        }
        glyph = &tmpGlyph;
    }

    if (fGenerateImageFromPath) {
        SkPath      devPath, fillPath;
        SkMatrix    fillToDevMatrix;
        SkMask      mask;

        this->internalGetPath(*glyph, &fillPath, &devPath, &fillToDevMatrix);
        glyph->toMask(&mask);

        if (fRasterizer) {
            mask.fFormat = SkMask::kA8_Format;
            sk_bzero(glyph->fImage, mask.computeImageSize());

            if (!fRasterizer->rasterize(fillPath, fillToDevMatrix, nullptr,
                                        fMaskFilter, &mask,
                                        SkMask::kJustRenderImage_CreateMode)) {
                return;
            }
            if (fPreBlend.isApplicable()) {
                applyLUTToA8Mask(mask, fPreBlend.fG);
            }
        } else {
            SkASSERT(SkMask::kARGB32_Format != mask.fFormat);
            generateMask(mask, devPath, fPreBlend);
        }
    } else {
        generateImage(*glyph);
    }

    if (fMaskFilter) {
        SkMask      srcM, dstM;
        SkMatrix    matrix;

        // the src glyph image shouldn't be 3D
        SkASSERT(SkMask::k3D_Format != glyph->fMaskFormat);

        SkAutoSMalloc<32*32> a8storage;
        glyph->toMask(&srcM);
        if (SkMask::kARGB32_Format == srcM.fFormat) {
            // now we need to extract the alpha-channel from the glyph's image
            // and copy it into a temp buffer, and then point srcM at that temp.
            srcM.fFormat = SkMask::kA8_Format;
            srcM.fRowBytes = SkAlign4(srcM.fBounds.width());
            size_t size = srcM.computeImageSize();
            a8storage.reset(size);
            srcM.fImage = (uint8_t*)a8storage.get();
            extract_alpha(srcM,
                          (const SkPMColor*)glyph->fImage, glyph->rowBytes());
        }

        fRec.getMatrixFrom2x2(&matrix);

        if (fMaskFilter->filterMask(&dstM, srcM, matrix, nullptr)) {
            int width = SkFastMin32(origGlyph.fWidth, dstM.fBounds.width());
            int height = SkFastMin32(origGlyph.fHeight, dstM.fBounds.height());
            int dstRB = origGlyph.rowBytes();
            int srcRB = dstM.fRowBytes;

            const uint8_t* src = (const uint8_t*)dstM.fImage;
            uint8_t* dst = (uint8_t*)origGlyph.fImage;

            if (SkMask::k3D_Format == dstM.fFormat) {
                // we have to copy 3 times as much
                height *= 3;
            }

            // clean out our glyph, since it may be larger than dstM
            //sk_bzero(dst, height * dstRB);

            while (--height >= 0) {
                memcpy(dst, src, width);
                src += srcRB;
                dst += dstRB;
            }
            SkMask::FreeImage(dstM.fImage);

            if (fPreBlendForFilter.isApplicable()) {
                applyLUTToA8Mask(srcM, fPreBlendForFilter.fG);
            }
        }
    }
}
Exemplo n.º 9
0
void Popover::setupUi(PopoverType type) {
    mType = type;
    switch(mType) {
    case Class:
        mForm = new PopoverClass();
        mForm->setupUi();
        break;
    case Package:
        mForm = new PopoverPackage();
        mForm->setupUi();
        break;
    case Primitive:
        mForm = new PopoverPrimitive();
        mForm->setupUi();
        break;
    case Enumeration:
        mForm = new PopoverEnumeration();
        mForm->setupUi();
        break;
    case Comment:
        mForm = new PopoverComment();
        mForm->setupUi();
        break;
    case Attribute:
        mForm = new PopoverAttribute();
        mForm->setupUi();
        break;
    case Literal:
        mForm = new PopoverLiteral();
        mForm->setupUi();
        break;
    case Operation:
        mForm = new PopoverOperation();
        mForm->setupUi();
        break;
    }

    if(mForm) {
        mLayout->addWidget(dynamic_cast<QWidget*>(mForm));
        auto location = findWindowLocation(mPos,
                dynamic_cast<QWidget*>(mForm)->width() + 20,
                dynamic_cast<QWidget*>(mForm)->height() + 20, mOrientation,
                QApplication::desktop()->availableGeometry(mMouse));

        setGeometry(location.first.x(), location.first.y(), 0, 0);
        setFixedSize(dynamic_cast<QWidget*>(mForm)->width() + 20,
                dynamic_cast<QWidget*>(mForm)->height() + 20);

        setLayout(mLayout);
        mLayout->setAlignment(Qt::AlignTop);

        int offset;
        if(mOrientation == Qt::Horizontal) {
            offset = mMouse.y() - location.first.y();
        } else {
            offset = mMouse.x() - location.first.x();
        }

        generateMask(location.second, offset);
    }
}
Exemplo n.º 10
0
unsigned int BitOperations::invertBitsUsingMask(const unsigned int num) {
// TODO invertBitsUsingMask
	return num ^ generateMask();
}
void SubPixelCorner::RefineCorner(cv::Mat image, std::vector< cv::Point2f > &corners) {

    if (enable == false)
        return;
    checkTerm();

    generateMask();
    // loop over all the corner points
    for (int k = 0; k < corners.size(); k++) {
        cv::Point2f curr_corner;
        // initial estimate
        cv::Point2f estimate_corner = corners[k];

        // cerr << 'SSS" << corners[k].x <<":" << corners[k].y << endl;

        if (estimate_corner.x < 0 || estimate_corner.y < 0 || estimate_corner.y > image.rows || estimate_corner.y > image.cols)
            continue;
        int iter = 0;
        double dist = TermCriteria::EPS;
        // loop till termination criteria is met
        do {
            iter = iter + 1;
            curr_corner = estimate_corner;

            /*
    Point cx;
    cx.x=floor(curr_corner.x);
    cx.y=floor(curr_corner.y);
    double dx=curr_corner.x-cx.x;
    double dy=curr_corner.y-cx.y;
    float vIx[2];
    float vIy[2];

    vIx[0] = dx;
    vIx[1] = 1 - dx;
    vIy[0] = dy;
    vIy[1] = 1 - dy;

    int x1=std::max((int)(cx.x-_winSize-_apertureSize/2),0);
    int y1=std::max((int)(cx.y-_winSize-_apertureSize/2),0);

    xmin = x1<0?0:x1;
    xmax = x1+_winSize<image.cols?x1+_winSize:image.cols-1;
    ymin = y1<0?0:y1;
    ymax = y1+_winSize<image.rows?y1+_winSize:image.rows-1;

    Rect roi=Rect(xmin,ymin,xmax-xmin,ymax-ymin);
    */

            Mat local;
            cv::getRectSubPix(image, Size(_winSize + 2 * (_apertureSize / 2), _winSize + 2 * (_apertureSize / 2)), curr_corner, local);



            cv::Mat Dx, Dy;
            // extracing image ROI about the corner point
            // Mat local=image(roi);
            // computing the gradients over the neighborhood about corner point
            cv::Sobel(local, Dx, CV_32FC(1), 1, 0, _apertureSize, 1, 0);
            cv::Sobel(local, Dy, CV_32FC(1), 0, 1, _apertureSize, 1, 0);

            // parameters requried for estimations
            double A = 0, B = 0, C = 0, D = 0, E = 0, F = 0;
            int lx = 0, ly = 0;
            for (int i = _apertureSize / 2; i <= _winSize; i++) {

                float *dx_ptr = Dx.ptr< float >(i);
                float *dy_ptr = Dy.ptr< float >(i);
                ly = i - _winSize / 2 - _apertureSize / 2;

                float *mask_ptr = mask.ptr< float >(ly + _winSize / 2);

                for (int j = _apertureSize / 2; j <= _winSize; j++) {

                    lx = j - _winSize / 2 - _apertureSize / 2;
                    // cerr << lx+_winSize/2 << ":" ;
                    double val = mask_ptr[lx + _winSize / 2];
                    double dxx = dx_ptr[j] * dx_ptr[j] * val;
                    double dyy = dy_ptr[j] * dy_ptr[j] * val;
                    double dxy = dx_ptr[j] * dy_ptr[j] * val;

                    A = A + dxx;
                    B = B + dxy;
                    E = E + dyy;
                    C = C + dxx * lx + dxy * ly;
                    F = F + dxy * lx + dyy * ly;
                }
            }

            // computing denominator
            double det = (A * E - B * B);
            if (fabs(det) > DBL_EPSILON * DBL_EPSILON) {
                det = 1.0 / det;
                // translating back to original corner and adding new estimates
                estimate_corner.x = curr_corner.x + ((C * E) - (B * F)) * det;
                estimate_corner.y = curr_corner.y + ((A * F) - (C * D)) * det;
            } else {
                estimate_corner.x = curr_corner.x;
                estimate_corner.y = curr_corner.y;
            }

            dist = pointDist(estimate_corner, curr_corner);


        } while (iter < _max_iters && dist > eps);

        // double dist=pointDist(corners[k],estimate_corner);
        if (fabs(corners[k].x - estimate_corner.x) > _winSize || fabs(corners[k].y - estimate_corner.y) > _winSize) {
            estimate_corner.x = corners[k].x;
            estimate_corner.y = corners[k].y;
        }
        corners[k].x = estimate_corner.x;
        corners[k].y = estimate_corner.y;
        // cerr << "EEE" << corners[k].x <<":" << corners[k].y << endl;
    }
}