Uncaught TypeError: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The provided double value is non-finite

Aaron Becker

I wrote some code to get data from a canvas on a website:

var checkPoints = ["+0,+0","+10,+10","+10,+0","+0,+10","-10,-10","-10,+0","+0,-10","+20,+20","+20,+0","+0,+20","-20,-20","-20,+0","+0,-20","+30,+30","+30,+0","+0,+30","-30,-30","-30,+0","+0,-30","+40,+40","+40,+0","+0,+40","-40,-40","-40,+0","+0,-40","+40,+40","+40,+0","+0,+40","-40,-40","-40,+0","+0,-40"];
var changePoints = ["600,0","-100,400","-100,300","600,580","-100,1000","1000,300","0,0","600,0","-100,400","-100,300","600,580","-100,1000","1000,300","0,0","600,0","-100,400","-100,300","600,580","-100,1000","1000,300","0,0","600,0","-100,400","-100,300","600,580","-100,1000","1000,300","0,0","600,0","-100,400","-100,300","600,580","-100,1000","1000,300","0,0"];
var checkRGB = [];
var oldCheckRGB = [];
for (i=0; i<checkPoints.length; i++) {
checkRGB.push("");
oldCheckRGB.push("");
}
var mousePos = myCanvas.relMouseCoords(e);
x = mousePos.x;
y = mousePos.y;
c = myCanvas.getContext("2d");
for (i=0; i<checkPoints.length; i++) {
    checkX = x+checkPoints[i].split(",")[0];
    checkY = y+checkPoints[i].split(",")[1];
    console.log("CheckX: "+checkX+", CheckY: "+checkY);
    checkRGB[i] = c.getImageData(x+checkX, y+checkY, ID("myCanvas").width, ID("myCanvas").height).data;
    if (checkRGB[i][0]-oldCheckRGB[i][0] > minimumColorChange || checkRGB[i][1]-oldCheckRGB[i][1] > minimumColorChange || checkRGB[i][2]-oldCheckRGB[i][2] > minimumColorChange) {
        xm = changePoints[i].split(",")[0];
        ym = changePoints[i].split(",")[1];
        console.log("XM set: "+xm+", YM set: "+ym);
    }
}

(This code is called every time the mouse is moved) And I keep getting the error: canvasTest.js:17 Uncaught TypeError: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The provided double value is non-finite.

I have done some searching around on stack overflow, google, and more and found nothing conclusive on this error or how to fix it.

Thanks for your help!

Adam Calvet Bohl

You are trying to add a value from the string array without any casting:

 checkX = x+checkPoints[i].split(",")[0];
 checkY = y+checkPoints[i].split(",")[1];

Maybe you should use:

 checkX = x + parseFloat(checkPoints[i].split(",")[0]);
 checkY = y + parseFloat(checkPoints[i].split(",")[1]);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Uncaught TypeMismatchError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D'

From Dev

Uncaught TypeMismatchError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D'

From Dev

JIC - Java Image Compressor : Failed to execute 'drawImage' on 'CanvasRenderingContext2D': No function was found that matched the signature

From Dev

Error "Uncaught TypeError: Failed to execute 'animate' on 'Element': Valid arities are: [1], but 4 arguments provided." on dynamic input field

From Dev

Uncaught InvalidStateError: Failed to execute 'dispatchEvent' on 'EventTarget': The event provided is null

From Dev

Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'

From Dev

Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'

From Dev

Uncaught TypeError: Failed to execute 'insertBefore' on 'Node': parameter 1 is not of type 'Node'

From Dev

Execute statement provided as a value

From Dev

Overriding CanvasRenderingContext2D.getImageData()

From Dev

Angularjs : Uncaught TypeError: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'

From Dev

polymer.html: Uncaught TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'

From Dev

Javascript error: Uncaught TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'

From Dev

Uncaught SyntaxError: Failed to execute 'querySelector' on 'Document'

From Java

Uncaught DOMException: Failed to execute 'postMessage' on 'Window'

From Dev

Uncaught NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope'

From Dev

Uncaught NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope'

From Dev

Three.js Uncaught SecurityError: Failed to execute 'texImage2D' on 'WebGLRenderingContext':

From Dev

Failed to execute 'getImageData' - The canvas has been tainted by cross-origin data

From Dev

Failed to execute 'getImageData' - The canvas has been tainted by cross-origin data

From Dev

Is there any method for `WebGLRenderingContext` as in `CanvasRenderingContext2D.getImageData()`?

From Java

Uncaught TypeError: (intermediate value)(...) is not a function

From Dev

"non-finite function value" when using integrate() in R

From Dev

Integration in R giving "non-finite function value"

From Dev

Failed to execute 'requestAnimationFrame' on 'Window': The callback provided as parameter 1 is not a function.

From Dev

Uncaught InvalidStateError: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state

From Dev

jQuery Chosen: Uncaught NotFoundError: Failed to execute 'appendChild' on 'Node':

From Dev

Uncaught DOMException: Failed to execute 'addRule' on 'CSSStyleSheet': Cannot access StyleSheet to insertRule

From Dev

Google cast receiver throwing "Uncaught NotSupportedError: Failed to execute 'addSourceBuffer' on 'MediaSource'

Related Related

  1. 1

    Uncaught TypeMismatchError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D'

  2. 2

    Uncaught TypeMismatchError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D'

  3. 3

    JIC - Java Image Compressor : Failed to execute 'drawImage' on 'CanvasRenderingContext2D': No function was found that matched the signature

  4. 4

    Error "Uncaught TypeError: Failed to execute 'animate' on 'Element': Valid arities are: [1], but 4 arguments provided." on dynamic input field

  5. 5

    Uncaught InvalidStateError: Failed to execute 'dispatchEvent' on 'EventTarget': The event provided is null

  6. 6

    Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'

  7. 7

    Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'

  8. 8

    Uncaught TypeError: Failed to execute 'insertBefore' on 'Node': parameter 1 is not of type 'Node'

  9. 9

    Execute statement provided as a value

  10. 10

    Overriding CanvasRenderingContext2D.getImageData()

  11. 11

    Angularjs : Uncaught TypeError: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'

  12. 12

    polymer.html: Uncaught TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'

  13. 13

    Javascript error: Uncaught TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'

  14. 14

    Uncaught SyntaxError: Failed to execute 'querySelector' on 'Document'

  15. 15

    Uncaught DOMException: Failed to execute 'postMessage' on 'Window'

  16. 16

    Uncaught NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope'

  17. 17

    Uncaught NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope'

  18. 18

    Three.js Uncaught SecurityError: Failed to execute 'texImage2D' on 'WebGLRenderingContext':

  19. 19

    Failed to execute 'getImageData' - The canvas has been tainted by cross-origin data

  20. 20

    Failed to execute 'getImageData' - The canvas has been tainted by cross-origin data

  21. 21

    Is there any method for `WebGLRenderingContext` as in `CanvasRenderingContext2D.getImageData()`?

  22. 22

    Uncaught TypeError: (intermediate value)(...) is not a function

  23. 23

    "non-finite function value" when using integrate() in R

  24. 24

    Integration in R giving "non-finite function value"

  25. 25

    Failed to execute 'requestAnimationFrame' on 'Window': The callback provided as parameter 1 is not a function.

  26. 26

    Uncaught InvalidStateError: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state

  27. 27

    jQuery Chosen: Uncaught NotFoundError: Failed to execute 'appendChild' on 'Node':

  28. 28

    Uncaught DOMException: Failed to execute 'addRule' on 'CSSStyleSheet': Cannot access StyleSheet to insertRule

  29. 29

    Google cast receiver throwing "Uncaught NotSupportedError: Failed to execute 'addSourceBuffer' on 'MediaSource'

HotTag

Archive