Just a note since this took me a while to track down. The OpenCV version on the TX2 after installing L4T is OpenCV 2.4.13.
OpenCV 2.4.13 appears to have an issue where it limits USB webcam frame captures to 640x480 even if you set the width / height to something else. When I do a set frame width or height with a webcam that supports higher resolutions, I get a HIGHGUI error and it ignores the dimensions set and leaves them at 640x480. This appears to be a known problem in some versions of OpenCV 2.4.12 and it appears to have carried over to 2.4.13.
One possible solution is to rebuild OpenCV 2.4.13 and fix the problem by hardcoding the resolution to the higher value I need. I believe the file to change is cap_v4l.cpp and the values are DEFAULT_V4L_WIDTH and DEFAULT_V4L_HEIGHT.
Alternatively, I could build OpenCV 3.1 or 3.2 and install it as it doesn’t have the problem.
However, either way I build myself, I end up with this:
“Note: Compiling OpenCV from source will not give you NVIDIA’s CPU optimizations that are only available in the closed-source prebuilt OpenCV4Tegra packages.”
You can read that here:
http://elinux.org/Jetson/Installing_OpenCV
For reference, this is another page showing how to uninstall OpenCV4Tegra and install OpenCV 3 on a TX1 since the process should be similar for the TX2
http://dev.t7.ai/jetson/opencv/
However, looking at others performance results after rebuilding either OpenVC 2 or 3 themselves, it looks like it is best to stay with the default OpenCV with the L4T distribution if possible.
So, one further approach I might attempt here is to edit the shared library binary files directly and change the 640 and 480 values where they are used (they appear to be used in 2 places) right in the libraries.
In the future, it would be nice to see OpenCV 3.2 supported with OpenCV4Tegra since it appears to have fixed this issue.