First at all, you should install Basler pylon Camera Software Suite in your machine. If not, please download and install it from the attached link below.

Link:
https://www.baslerweb.com/en/sales-support/downloads/software-downloads/#type=pylonsoftware;version=all

If you are using Windows machine, follow the guide below to install Python, Pypylon and OpenCV into your system in order to use Basler camera with OpenCV.

1. Install Python from Link: https://www.python.org/downloads/

2. Open command prompt: search > cmd

3. Copy the command below to the console.
      pip install opencv-contrib-python

4. When the installation is completed, type python and press enter

5. Type import cv2

6. Check opencv version by using the command below, it will show the installed OpenCV version.
        cv2.__version__

7. Command exit() 

8. Command pip install pypylon to install pypylon in order to use Basler camera.

Congratulations. You have completed all the steps. 
You should be able to use Basler camera with OpenCV now.