how can I have two opencv on tx2

I already have opencv2.4 on tx2,but I need opencv 3 to use the camera,can I have 2 opencv and choose whatever I want to use? thanks

Yes, you can do this.
Note that from R28.2, there is no longer opencv4tegra-2.4.

Opencv4tegra is installed in /usr.
When configuring your opencv3 build with cmake, set CMAKE_INSTALL_PREFIX to another path than default /usr (for example, I use /usr/local/opencv-3.3.1).

When you want to build your app for opencv3, you have to specify path to include and lib such as:

gcc -Wall -oyour_app <b>-I/usr/local/opencv-3.3.1/include</b> your_app.cpp <b>-L/usr/local/opencv-3.3.1/lib</b> -lopencv_core -l<another_opencv_lib> ...

When you want to run your app built against opencv3, you will first have to add opencv3 libs path to environment variable LD_LIBRARY_PATH such as:

export LD_LIBRARY_PATH=/usr/local/opencv-3.3.1/lib:/usr/local/cuda/lib64

Note also that some projects have cmake or makefile using pkg-config for getting flags:

pkg-config --cflags opencv
pkg-config --libs opencv

By default it should find opencv4tegra’s config. If you want it to return opencv3’s config, you may save opencv4tegra’s file and use a symbolic link pointing to opencv3 config:

sudo su
cd /usr/lib/pkgconfig
mv opencv.pc opencv4tegra.pc
ln -s /usr/local/opencv-3.3.1/lib/pkgconfig/opencv.pc

It is also useful to print at run time some info about the used libraries. Check macros CV_VERSION, CV_MAJOR_VERSION,CV_MINOR_VERSION and function cv::getBuildInformation().

[EDIT: if you are using cmake, you may run into trouble with opencv4tegra being installed in /usr, and cmake finding by default its cmake settings in /usr/share/OpenCV, so you would use something like this before configuring a project build with cmake:

OpenCV_DIR=/usr/local/opencv-3.3.1 cmake <project_src_dir>