<PAGE>
                                                                   EXHIBIT 10.31

                               SECOND AMENDMENT TO
                         AMENDED AND RESTATED REVOLVING
                          CREDIT AND SECURITY AGREEMENT

      THIS SECOND AMENDMENT TO AMENDED AND RESTATED REVOLVING CREDIT AND
SECURITY AGREEMENT ("Amendment"), dated as of August 6, 2004, is by and among
ROBOTIC VISION SYSTEMS, INC., a corporation organized under the laws of the
State of Delaware ("Borrower"), RVSI INVESTORS, L.L.C., a limited liability
company organized under the laws of the State of Delaware ("RI") and the other
lenders which are now or which hereafter become a party to the Credit Agreement
referred to below (collectively, "Lenders" and individually a "Lender") and PNC
BANK, NATIONAL ASSOCIATION ("PNC"), as agent for Lenders (PNC, in such capacity,
"Agent").

                                    RECITALS

      A. Agent, RI, as a Lender, and Borrower are parties to a certain Amended
and Restated Revolving Credit and Security Agreement dated as of November 26,
2003, as same may be amended, restated or replaced from time to time, including
pursuant to the First Amendment (defined below) (the "Credit Agreement"),
pursuant to which Lender has agreed to extend financial accommodations to
Borrower as described therein.

      B. Agent, RI, as a Lender, and Borrower entered into a certain First
Amendment to Amended and Restated Revolving Credit and Security Agreement dated
as of June 25, 2004 (the "First Amendment").

      C. On or about July 26, 2004 Borrower received gross cash proceeds of
sales of Common Stock in the amount of approximately $2,400,000 and such
proceeds were delivered to Agent and applied to repay interest due in respect of
the Revolving Advances and in consequence thereof Borrower has requested an
increase in the Maximum Non-Guaranteed Revolving Advance Amount and, in
connection therewith, Borrower has requested that Agent and Lender amend the
definition of "Additional Maximum Non-Guaranteed Revolving Advance Amount" in
the Credit Agreement in order to make available $2,000,000 in Borrower's
revolving line of credit thereunder. Subject to the terms and conditions set
forth herein, Agent and Lender have agreed to such request as provided herein.

      D. Borrower has requested and Agent and Lender have agreed to amend the
Credit Agreement as provided herein.

      NOW, THEREFORE, for and in consideration of the foregoing premises and for
other good and valuable consideration, the receipt and sufficiency of which are
hereby acknowledged, the parties hereto agree as follows:

      1. DEFINITIONS. All capitalized terms used herein and not otherwise
defined shall have the meanings provided for in the Credit Agreement.

<PAGE>

      2. AMENDMENT. Upon satisfaction of the conditions precedent set forth in
Section 3 of this Amendment, the Credit Agreement is hereby amended as follows:

            2.1. Section 1 of the Credit Agreement is hereby amended by:

                  (a) amending and restating the defined term "Additional
            Maximum Non-Guaranteed Revolving Advance Amount" set forth therein,
            as follows:

                        "Additional Maximum Non-Guaranteed Revolving Advance
                        Amount" shall mean $2,000,000.

      3. CONDITIONS PRECEDENT. The amendments set forth in Section 2 above shall
be effective upon the execution and delivery of this Amendment by Borrower,
Agent and Lender and the delivery to Agent (or, in the case of the Additional
Shares described in clause (b) below, to Lender) of the following, all in form
and substance acceptable to Agent and Lender:

                  (a) required third party consents in respect of the terms of
            this Amendment, including that of the Export-Import Bank of the
            United States ("EXIM");

                  (b) 19,710 shares of Borrower's Common Stock issued to RI (the
            "Additional Shares"), all of which Additional Shares shall be duly
            authorized, validly issued, fully paid, and nonassessable as of the
            date of issuance thereof, shall be deemed Registrable Securities (as
            such term is defined in that certain Registration Rights Agreement
            dated as of June 25, 2004 made by and between Borrower and RI (the
            "June 2004 Registration Rights Agreement")), and shall be registered
            on the next-filed registration statement that may be used for the
            registration of such Additional Shares, but in no event no later
            than the Effectiveness Deadline Date (as that term is defined in the
            June 2004 Registration Rights Agreement) (with Borrower agreeing to
            all of the foregoing by its signature below);

                  (c) Reaffirmation of that certain Subordination, Forbearance
            and Waiver of Offset Rights Agreement dated April 11, 2003 executed
            by Pat V. Costa and Borrower; and

                  (d) such other documents as Agent and Lender may reasonably
            request in connection with this Amendment.

Reference is made to the First Amendment. By their signatures below, the parties
hereto acknowledge and agree that each of the conditions precedent to the
effectiveness of the First Amendment have been either satisfied or waived.

                                      -2-

<PAGE>

      4. EXPENSES. Borrower shall pay all fees, costs and expenses incurred by,
or charged by Agent, Lender and EXIM in connection with this Amendment and the
agreements, documents and other items contemplated hereunder.

      5. REAFFIRMATION OF GRANTS OF SECURITY INTERESTS. Borrower heretofore or
hereafter expressly acknowledges and agrees that all collateral, security
interests, liens, pledges and mortgages heretofore or hereafter granted to Agent
and Lender including, without limitation, such collateral, security interests,
liens, pledges and mortgages granted under the Credit Agreement and all
supplements thereto, or any of the Other Documents and all supplements thereto,
extend to and secure all of the obligations of Borrower to Agent and Lender, now
existing or hereafter arising including, without limitation, those arising in
connection with the Credit Agreement, as amended by this Amendment, upon the
terms set forth in such agreements, all of which security interests, liens,
pledges and mortgages are hereby ratified, reaffirmed, confirmed and approved.

      6. MISCELLANEOUS.

            6.1. LIMITED NATURE OF AMENDMENT. The parties hereto acknowledge and
agree that the terms and provisions of this Amendment amend, add to and
constitute a part of the Credit Agreement. Except as expressly waived or
modified and amended by the terms of this Amendment, all of the other terms and
conditions of the Credit Agreement and all documents executed in connection
therewith or referred to or incorporated therein remain in full force and effect
and are hereby ratified, reaffirmed, confirmed and approved.

            6.2. CONFLICT. If there is an express conflict between the terms of
this Amendment and the terms of the Credit Agreement, or any of the other
agreements or documents executed in connection therewith or referred to or
incorporated therein, the terms of this Amendment shall govern and control.

            6.3. COUNTERPARTS. This Amendment may be executed in one or more
counterparts, each of which shall be deemed to be an original.

            6.4. REPRESENTATIONS AND WARRANTIES. Borrower represents and
warrants to Agent and Lender as follows: (A) Borrower has all necessary
corporate power and authority to execute and deliver this Amendment and perform
its obligations hereunder; (B) this Amendment and the Credit Agreement, as
amended hereby, constitute the legal, valid and binding obligations of Borrower
and are enforceable against Borrower in accordance with their terms; and (C) all
representations and warranties of Borrower contained in the Credit Agreement,
the Other Documents and all other agreements, instruments and other writings
relating thereto are true and complete as of the date hereof.

            6.5. RESERVATION OF RIGHTS, RELEASE AND COVENANT NOT TO SUE.

            (a) Reference is made to that certain letter from Agent and Lender
      to Borrower dated June 23, 2004 reserving all rights with respect to
      certain Events of Default specified therein (the "Reservation of Rights
      Letter"). It is


                                      -3-

<PAGE>

      agreed and understood that the terms of the Reservation of Rights Letter
      are reaffirmed in all respects and that nothing herein shall be construed
      as a waiver of any existing Events of Default. Borrower hereby
      acknowledges and agrees that it has no defenses, offsets, recoupment,
      claims or counterclaims against or with respect to Agent or any Lender or
      against the enforcement of the Credit Agreement or any of the Other
      Documents, as modified hereby, and that the Agent and each Lender have not
      waived any of their respective rights or remedies under any such documents
      (individually and collectively "Defenses").

            (b) Borrower hereby forever releases and discharges each Released
      Party (defined below), jointly and severally, from any and all claims,
      demands, controversies, actions, causes of action, obligations,
      liabilities, costs, expenses, fees (including attorneys' and other
      professionals' fees, costs and expenses), and damages of whatsoever
      character, nature and kind, at law or in equity, which Borrower may now
      have against the Released Parties, or any of them, or which Borrower ever
      had, or which Borrower, its respective representatives, successors or
      assigns hereafter can, shall or may have, arising from or related in any
      way to the Credit Agreement, this Amendment or any of the Other Documents,
      or for, upon, or by reason of any other matter, cause or thing whatsoever,
      whether or not related in any way to the Credit Agreement, this Amendment
      or any of the Other Documents, arising or relating to the period prior to
      the date hereof (individually and collectively "Liabilities"). It is the
      intention of the parties hereto that the foregoing acknowledgment and
      release shall be effective as a bar to all Defenses and Liabilities, past
      and present, known and unknown, suspected and unsuspected arising from or
      in any way related to any act or omission) of any kind whatsoever, by any
      Released Party in any capacity whatsoever, occurring or commencing prior
      to the date hereof, including without limitation any act or omission, or
      series of similar or related acts or omissions, commencing prior to the
      date hereof and continuing after the date hereof. "Released Party" means
      (i) Agent, (ii) each Lender, (iii) each direct and indirect member of each
      Lender, (iv) each direct and indirect affiliate of Agent, each Lender and
      each direct and indirect member of each Lender, (v) each officer,
      director, member, partner, equity owner, agent, servant, employee,
      attorney and other representative of each of the Released Parties
      identified in clauses (i) through (iv) of this sentence, and (vi) each
      successor and assign of each Released Party.

            (c) In addition, in order to further induce Agent and Lender to
      enter this Amendment, and for other good and valuable consideration, the
      receipt and sufficiency of which are hereby acknowledged, Borrower, on
      behalf of itself and its successors, assigns, and other legal
      representatives, hereby absolutely, unconditionally and irrevocably,
      covenants and agrees with and in favor of each Released Party that it will
      not sue (at law, in equity, in any regulatory proceeding or otherwise) any
      Released Party on the basis of any

                                      -4-

<PAGE>

      Liabilities. If Borrower or any of its successors, assigns or other legal
      representatives violates the foregoing covenant, Borrower, for itself and
      its successors, assigns and legal representatives, agrees to pay, in
      addition to such other damages as any Released Party may sustain as a
      result of such violation, all attorneys' fees and costs incurred by any
      Released Party as a result of such violation. Borrower hereby covenants
      and agrees that, but for the granting of this covenant pursuant to this
      Amendment, neither Agent nor Lender would have entered into this
      Amendment, and both Agent and Lender are materially relying hereon in
      entering into this Amendment.

            6.6. GOVERNING LAW. This Amendment shall be governed by and
construed in accordance with the internal laws (as opposed to conflicts of law
provisions) of the State of New York.

                            [SIGNATURE PAGE FOLLOWS]

                                      -5-

<PAGE>

      IN WITNESS WHEREOF, each of the parties has signed this Amendment as of
the day and year first above written.

                                BORROWER:

                                ROBOTIC VISION SYSTEMS, INC.

                                By: /s/ Jeffrey P. Lucas
                                   _________________________________________
                                Name:_______________________________________
                                Title:______________________________________



                                AGENT:

                                PNC BANK, NATIONAL ASSOCIATION, as Agent


                                By: /s/ Patrick McConnell
                                   _________________________________________
                                Name:_______________________________________
                                Title:______________________________________



                                LENDER:

                                RVSI INVESTORS, L.L.C., as Lender


                                By:      EGI-FUND (02-04) INVESTORS, L.L.C., its
                                         Managing Member

                                         By: /s/ Donald J. Liebentritt
                                            ____________________________________
                                         Name:__________________________________
                                         Title:_________________________________

                                      -6-