Specifying a lens for an imaging system can seem like a complex task, so the key is breaking the selection down into manageable pieces. Pieces such as resolution, working distance, depth of field, and field of view are all part of the greater whole and each falls directly out of what must be accomplished for the application.  
Let’s start with field of view, which is simply the size of the area that you need to image with your system. The key here is making sure that you specify field of view in a way that allows you to match it up with lens specifications. The complication is that most sensors in machine vision cameras are rectangular shaped, typically with a 4:3 aspect ratio. This leads to the lens field of view potentially being specified in three different ways: horizontal field of view (the longer length of the sensor), vertical field of view (the shorter length of the sensor) or diagonal field of view (corner to corner length).  Because of this, always make sure to think of the whole area that the object(s) being imaged will take up. A 6 inch x 1 inch object would require a different lens than a 6 inch x 6 inch object.
Field of view can also be thought of in terms of magnification, but this can be a more complicated way to think of it because it requires you to have locked down your sensor size before you can specify it. Now to fully understand the system, it helps to know how sensor sizes are specified and what they really mean. Unfortunately, this is complicated by the fact that sensor sizes do not equal their name, meaning that a ½-inch size sensor does not equal 12.7 millimeter (mm) for any dimension. This stems from the days when cameras had glass tubes and the size was specifying the outer dimension of that tube. As a rough approximation this typically comes out to a diagonal dimension that is close to a third less than the “size.”  Now let’s take a 2/3-inch sensor and relate that back to magnification, typically the sensor dimensions would be 8.8 x 6.6 mm. Let’s say that we wanted a 2x magnification, which would result in a field of view of 4.4 x 3.3 mm. Specifying in terms of magnification requires you to know your sensor and field of view ahead of time, so it is more useful when picking between lenses.

More Specifications

Another critical specification is the working distance range that you can work within. It is important to know that working distance is almost always defined as the distance from the object being imaged and front-most surface of the lens; it does not include the length of the lens itself. So if you are working within a constrained package size it is important to understand the system length that you can have, which is the working distance + length of lens + length of camera. With a fixed magnification lens (often 0.01x and higher), the working distance is merely another lens specification, but with a fixed focal length lens, the working distance directly determines the field of view that you will achieve. This is why a fixed focal length lens will specify its field of view in term of an angular value and it requires just a little trigonometry to determine the resulting field. To give you an idea, a 25 mm focal length lens will have twice the field of view at 600 mm than it would at 300 mm, so the more flexibility to your working distance the easier it is to find a lens that will match up.
Now fundamental to every imaging system is understanding the resolution requirements and matching a lens to that need. The best way to start thinking about the resolution that you need is to determine the smallest sized feature that you need to resolve. Once you have determined this, you must relate it to the field of view that you have determined you will need. This is because needing to resolve 0.1 mm details with a 4x3 mm field of view is a much lower resolution requirement than needing to resolve 0.1 mm details with a 400x300 mm field of view would be. Resolution for a lens is typically specified in terms of line pairs per millimeter (lp/mm) versus the contrast achieved (between a true black and true white line); this is referred to as the MTF (modulation transfer function) of the lens. If a lens has resolution of 100 lp/mm, that translates to a resolution of 10 microns, or µm (1/100), at the image (sensor) plane.  Now this can be related back to our object resolution by dividing by the magnification that was determined. So if the magnification that you need is 0.5x, this would result in a limiting resolution of 20µm. While not always provided, any lens manufacturer should be able to provide an MTF so that you can determine the resolution at the field of view that you need (or they can do this for you if you provide this information).
Lastly, it is necessary to know what depth of field you require. The depth of field is distance that the lens can resolve around the working distance that you are focused on. This is important if the object that you are viewing has any height to it that you need to image through—think of components on a circuit board. Typically, lenses have a specified depth of field that has a resolution or contrast that is less than at the stated working distance, so it is often best to ask the lens provider to tell you what the depth of field is with the parameters that you determine (working distance and the resolution needed through the depth).  Now to make matters just a bit more complicated, the depth of field is heavily influenced by the aperture setting of the lens. A fixed focal length set with an f/# of f/1.4 will have much smaller depth of field than the same lens set at f/2.8, but it will also have decreased light throughput and a different resolution. Always make sure that you get values from the lens manufacturer that are at the settings you plan to use them at and not the values at idealized settings.
Understanding the basic specifications of a lens system makes narrowing down your selection of lens much easier and allows you to evaluate lenses that you have determined so that you can make sure to find one that is just right and not one that underperforms in your application or one gives you costly over-performance. Now these are not the only things to keep in mind when choosing a lens—there are many other parameters that can affect things such as wavelength, distortion, f/#, and whether or not to go telecentric—but these will get you started and are necessary to know for every application.