Expectations were low going into Cognex's (CGNX 1.85%) second-quarter financial report. The machine-vision leader had signaled that 2019 would be a challenging year, due to slower growth in China and weakness in two of the major industries the company serves.

Investors breathed a sigh of relief when the results weren't as bad as expected, sending the shares up more than 8% in the wake of Monday's report. Let's dig a little deeper into the results to see what sparked the boost of enthusiasm for the company.

A robotic arm using machine vision in cellphone manufacturing

Image source: Getty Images.

Declining revenue and earnings

Cognex reported revenue of $199 million, down about 6% year over year, though it was only down 3% in constant currency. This bested analysts' consensus estimates of $195 million, while also coming in at the high end of management's forecast range of between $190 million and $200 million.

Gross margin was 74%, within management's forecast "in the mid-70% range." This resulted in net income of $48.75 million and diluted earnings per share of $0.28, down from $0.32 in the year-ago quarter, and below the $0.30 expected by analysts.

Cognex also declared a quarterly cash dividend of $0.05, payable on Aug. 30 to shareholders of record as of Aug. 16.

Challenges remain

On the conference call, Cognex CEO Robert Willett said that lower spending by customers in the consumer electronics and automotive sectors in the Americas -- which together have accounted for about 50% of the company's revenue -- played out much as management had expected. Willett said both segments are "contracting simultaneously for the first time in many years."

He pointed out that many customers exposed to the slowdown in China were reducing and deferring large projects until the situation stabilizes. Willett also warned that the factory automation market in Europe was considerably softer than Cognex had anticipated, and the impact would be more noticeable in the third quarter.

It wasn't all bad news. On the plus side, Cognex is enjoying the continued migration of businesses to e-commerce, as the company saw strong demand in its logistics segment -- up about 50% year over year -- which made up much of the shortfall in the manufacturing sector.

Also, many companies are investing in automation to speed their fulfillment operations, and machine vision is a key component of that technology. This is currently a small, but growing, part of Cognex's business, and Willett said: "We think we can keep growing this market at [a] 50% growth rate over the long term."

What to look for in the coming quarter

Given the challenges the company is facing, Cognex is being even more conservative than usual with its forward-looking guidance. For the third quarter, management forecasts revenue in a range of $175 million to $185 million, which would be a decline of between 20% and 25% compared to the prior-year quarter. (To put that into the context of Wall Street sentiment, analysts' consensus estimates are currently calling for revenue of $213 million and earnings per share of $0.32.)

This is almost entirely the result of the decline in the consumer electronics segment, which saw unusually strong demand related to smartphone manufacturing last year. The company is also guiding for gross margin "in the mid-70% range," and expecting operating expenses to be essentially flat compared to the current quarter -- at about $96.3 million.

Cognex is focusing its efforts on high-growth areas of its business and reining in expenses, which is really all the company can do to ride out the current difficulties. Investors appear to be relieved that Cognex has done as well as it has in this challenging environment.