The problem you want to solve is definitely a SLAM problem and not just simply localization (or maybe we can consider it SLAm since the mapping part is not as heavy). The reason for this is that you will need to do some kind of mapping for initialization when you set up the environment. Of course you could set up the environment with markers or known features and carefully position them so that you know the map immediately, but that process is a lot harder than most people imagine.
Based on your question and the comments you've provided in CroCo's answer (which, by the way, is still a decent answer but I would like to expand), I see two paths that you can take which shouldn't be too difficult given all the resources available out there:
Vision-based: Use fiduciary markers (QR codes or typical black and white checker patterns like you see on crash-test dummies), then locate these markers using computer vision feature recognition algorithms (OpenCV can do this easily using something like SURF). You can perform the initial mapping by using a graph-based SLAM approach (not real-time, record a bunch of data and crunch it all at once), then do localization only in real-time using a simplified bundle adjustment approach (with just one single image and enough visible features).
LiDAR-based: Rely generally on ICP registration with your reference point cloud (pre-built map) and a fresh scan from the sensor. Note that to do this you need to use a scanner on your stick instead of a camera. It will be almost impossible to build the map with laser scan data and then localize inside it with a camera. I say "almost" because there does exist a body of research that relies on monocular cameras for generating 3D data from 2D images (shape from shading, for example), but that is going to be a much bigger challenge than I suspect you want to tackle.
Another interesting option is to use something like the X-Box Kinect (v1 or v2) so that you can get both 2D camera data and 3D scanning at the same time. With that approach you can then identify features in the camera images but have them linked to 3D coordinates in the scan data. Here is an example of the Kinect being used for indoor SLAM.
Some of the challenges you will encounter will be motion blur and even rolling shutter issues if you are using a fast-moving camera point-of-view. Your problem could be solved simply by considering a new image, identifying the features in that image, and then simple camera 3D reconstruction (again using OpenCV's camera reconstruction tools would be recommended).
I also suggest checking into using ROS, which provides a lot of the components for solving your problem already built and ready for implementation using a variety of different sensors.
Another thing that you haven't mentioned (and is alluded to in CroCo's answer) is that you can use an IMU (integrated accelerometer, gyroscope, and possibly magnetometer) to provide motion estimates of the camera itself. This is not sufficient alone but can make real-time pose estimation much easier (actually, most of us would consider it crucial). With the use of an IMU and camera/scanner data, you can then use an EKF or particle filter as has been suggested.