예제 #1
0
//-----------------------------------------------------------------------------
CMouseEventResult CSegmentButton::onMouseDown (CPoint& where, const CButtonState& buttons)
{
	if (buttons.isLeftButton ())
	{
		float newValue = 0;
		float valueOffset = 1.f / (segments.size () - 1);
		uint32_t currentIndex = getSegmentIndex (getValueNormalized ());
		for (Segments::const_iterator it = segments.begin (), end = segments.end (); it != end; ++it, newValue += valueOffset)
		{
			if ((*it).rect.pointInside (where))
			{
				uint32_t newIndex = getSegmentIndex (newValue);
				if (newIndex != currentIndex)
				{
					beginEdit ();
					setSelectedSegment (newIndex);
					valueChanged ();
					endEdit ();
					invalid ();
				}
				break;
			}
		}
	}
	return kMouseDownEventHandledButDontNeedMovedOrUpEvents;
}
SplineVector3D LoopingCubicHermiteSpline::getPosition(double x) const
{
    //use modular arithmetic to bring x into an acceptable range
    x = fmod(x, numSegments);
    if(x < 0)
        x += numSegments;

    //find the interpolation data for this t value
    InterpolationData segment = segmentData.at(getSegmentIndex(x));
    double t = (x - segment.t0) * segment.tDistanceInverse;

    return computePosition(t, segment);
}
예제 #3
0
//-----------------------------------------------------------------------------
int32_t CSegmentButton::onKeyDown (VstKeyCode& keyCode)
{
	int32_t result = -1;
	if (keyCode.modifier == 0 && keyCode.character == 0)
	{
		uint32_t newIndex = getSegmentIndex (getValueNormalized ());
		uint32_t oldIndex = newIndex;
		switch (keyCode.virt)
		{
			case VKEY_LEFT:
			{
				if (style == kHorizontal && newIndex > 0)
					newIndex--;
				result = 1;
				break;
			}
			case VKEY_RIGHT:
			{
				if (style == kHorizontal && newIndex < segments.size () - 1)
					newIndex++;
				result = 1;
				break;
			}
			case VKEY_UP:
			{
				if (style == kVertical && newIndex > 0)
					newIndex--;
				result = 1;
				break;
			}
			case VKEY_DOWN:
			{
				if (style == kVertical && newIndex < segments.size () - 1)
					newIndex++;
				result = 1;
				break;
			}
		}
		if (newIndex != oldIndex)
		{
			beginEdit ();
			setSelectedSegment (newIndex);
			valueChanged ();
			endEdit ();
			invalid ();
		}
	}
	return result;
}
Spline::InterpolatedPTCW LoopingCubicHermiteSpline::getWiggle(double x) const
{
    //use modular arithmetic to bring x into an acceptable range
    x = fmod(x, numSegments);
    if(x < 0)
        x += numSegments;

    InterpolationData segment = segmentData.at(getSegmentIndex(x));
    double t = (x - segment.t0) * segment.tDistanceInverse;

    return InterpolatedPTCW(
                computePosition(t, segment),
                computeTangent(t, segment),
                computeCurvature(t, segment),
                computeWiggle(segment)
                );
}
예제 #5
0
//-----------------------------------------------------------------------------
uint32_t CSegmentButton::getSelectedSegment () const
{
	return getSegmentIndex (getValueNormalized ());
}
예제 #6
0
/**
 * OCR process from gray image input
 */
int ocrProcess(Image binImg) {

    int i, h, w;
    h = binImg.h;
    w = binImg.w;
    int count =0, lCount = 0;

    int start = 0;
    int endLine = 0;
    int nLine;
    Rect rect;

    int* charIndex[20];

    system("rm -rf data");
    system("mkdir -p data");
    system("rm -rf leven");
    system("mkdir -p leven");


    createNetworkFromFile();

    /// segmentation processing
    while((nLine = ccLineLabeling(binImg, start))!= 0) {
        if(nLine < 3) continue;
        printf("%d\n",nLine);
        int baseLine = getBaselineHeight(nLine);

//        int avgSpace = getAverageSpace(nLine);
        /// get slant deg
        int slantDeg = getSlantDeg(binImg, baseLine, nLine);
//        printf("slantDeg = %d\n", slantDeg);

        int nChar = 0;

        for(i = 0; i < nLine; i++) {
            int index = getSegmentIndex(i);
//            printf("%d ", index);
            rect = getCharRect(index);
            endLine = endLine > (rect.y + rect.h) ? endLine :(rect.y + rect.h);
            Image charImg = getImageFromRect(binImg, rect, index);
            if(slantDeg) {
                charImg = slantRemoval(charImg, slantDeg);
            }
//            char* name = (char*) malloc(20* sizeof(char));
//            sprintf(name, "out_s_%d_%d.txt", lCount, i);
//            printImage(charImg, name);

            charImg = contourFinding(charImg);
            smoothContour(charImg);
            thinImageOnMatch(charImg);
            double* input = getFeature(charImg);
            double prop, maxProp = 0.0;

            /// recognition
            nChar++;
            charIndex[nChar-1] = charRecognition(input, &prop);


            /// check space
            //int space = getSpace(i, nLine, binImg);
            //if(space > baseLine/2) {//printf(" ");
            //    createWordFst(charIndex, nChar);
            //    nChar = 0;
            //    printf(" ");
            //}
            deleteImage(charImg);
            free(input);
            count++;
//            }
//            printf(" ");
//            start_w = end_w;
//            deleteImage(wordImg);
        }
        printf("\n");
        start = endLine;
        lCount++;
    }
    deleteImage(binImg);
    deleteNetwork();
    printf("%d\n", count);
    return 0;
}