EXHIBIT 23.1

            CONSENT OF INDEPENDENT REGISTERED PUBLIC ACCOUNTING FIRM

We consent to the incorporation by reference in this Annual Report (Form 10-K)
of Cognex Corporation of our report dated March 4, 2005, included in the 2004
Annual Report to Shareholders of Cognex Corporation.

We consent to the incorporation by reference in the Registration Statements on
Form S-8 (File Nos. 33-81150, 333-04621, 333-02151, 333-60807, 33-32815,
333-44824, 333-68158, 333-96961, and 333-100709) of Cognex Corporation of our
report dated March 4, 2005, with respect to the consolidated financial
statements of Cognex Corporation incorporated by reference in this Annual Report
(Form 10-K) for the years ended December 31, 2004 and 2003, our report dated
March 4, 2005 with respect to Cognex Corporation management's assessment of the
effectiveness of internal control over financial reporting and the effectiveness
of internal control over financial reporting included in this Annual Report
(Form 10-K), and our report dated March 4, 2005 with respect to the financial
statement schedule of Cognex Corporation and subsidiaries for the years ended
December 31, 2004 and 2003 included in this Annual Report (Form 10-K).

/s/ Ernst & Young LLP

Boston, Massachusetts
March 4, 2005