Пример #1
0
    private void initDefaultData()
    {
        fishID = 0; // if scanner module couldn't found QR code then just use fish 0 as default.

        fishMaskCount = 10;

        isFishFileReady = false;

        interimImage  = null;
        webCam        = null;
        scannerThread = null;
        isScannerBusy = false;
        isDebugMode   = false;       // use this flag to turn on/off debug mode

        scannerMode = SCANNER_MODE.SIMULATION;

        FILE_SEP = '_';

        maskImageName = "fishmask"; // for testing

        fishName       = "00000";
        fishNameHeader = "fish_scanned" + FILE_SEP;

        cameraSize.Set(0, 0, 1920, 1080);

        setCodeAndCameraArea();

        createObjects();

        loadMaskImage();

        initCamera();
    }
Пример #2
0
    private void createObjects()
    {
        fishMasks = new AQTexture2D[fishMaskCount];

        scannerThread = new Thread(procImage);

        fishCodeReader = new BarcodeReader();

        orgImage          = new Texture2D((int)cameraSize.width, (int)cameraSize.height, TextureFormat.RGBA32, false);
        fishIDTestTexture = new Texture2D((int)codeArea[0].width, (int)codeArea[0].height, TextureFormat.RGBA32, false);

        fishIDImage  = new AQTexture2D((int)codeArea[0].width, (int)codeArea[0].height);
        interimImage = new AQTexture2D((int)cameraSize.width, (int)cameraSize.height);
    }
Пример #3
0
    private void loadMaskImage()
    {
        String    tempImageName;
        Texture2D tempMaskImage;

        for (int i = 0; i < fishMaskCount; i++)
        {
            tempImageName = maskImageName + FILE_SEP + String.Format("{0:00}", i);

            tempMaskImage = new Texture2D((int)cameraSize.width, (int)cameraSize.height, TextureFormat.RGBA32, false);

            tempMaskImage = Resources.Load(tempImageName) as Texture2D;

            fishMasks[i] = new AQTexture2D(tempMaskImage.width, tempMaskImage.height);

            fishMasks[i].SetPixels(tempMaskImage.GetPixels(0, 0, tempMaskImage.width, tempMaskImage.height));
        }
    }
Пример #4
0
    private void ProcessFinalImage()
    {
        Color colorOrgImage;
        int   width, height;
        int   minX, minY;
        int   maxX, maxY;
        int   finalWidth, finalHeight;

        minX = 2000;
        minY = 2000;

        maxX = -2000;
        maxY = -2000;

        width  = interimImage.width;
        height = interimImage.height;

        for (int y = 0; y < height; y++)
        {
            for (int x = 0; x < width; x++)
            {
                colorOrgImage   = interimImage.GetPixel(x, y);
                colorOrgImage.a = fishMasks[fishID].GetPixel(x, y).r;

                interimImage.SetPixel(x, y, colorOrgImage);

                /*
                 * [0.0.2] we don't need this anymore but don't delete until the final release. 2018.06.20 John
                 * [0.0.4] yes, don't use this for final release. 2018.09.13 John
                 * if (colorOrgImage.a.Equals(0.0f) == false)
                 * {
                 *  if (x < minX)
                 *  {
                 *      minX = x;
                 *  }
                 *
                 *  if (y < minY)
                 *  {
                 *      minY = y;
                 *  }
                 *
                 *  if (x > maxX)
                 *  {
                 *      maxX = x;
                 *  }
                 *
                 *  if (y > maxY)
                 *  {
                 *      maxY = y;
                 *  }
                 * }*/
            }
        }


        // [0.0.2] Now we need fixed area for cropping fish image. 2018.06.20 John
        // [0.0.4] New fixed area for final release. 2018.09.13 John

        minX = 461;
        minY = 236;

        maxX = 1466;
        maxY = 944;

        finalImage = null;

        finalWidth  = (maxX - minX);
        finalHeight = (maxY - minY);

        finalImage = new AQTexture2D(finalWidth, finalHeight);

        for (int y = minY; y < maxY; y++)
        {
            for (int x = minX; x < maxX; x++)
            {
                finalImage.SetPixel((x - minX), (y - minY), interimImage.GetPixel(x, y));
            }
        }

        finalImage.flip(); //[002] make sure we need to flip because of the up vector of the camera. John. 2018.06.15

        Debug.Log("The final image is ready!");
        Debug.Log("Done :" + MethodBase.GetCurrentMethod().Name);

        isFishFileReady = true;
    }