I've tried to keep your budget as close to $500 as possible making every micro optimization that I know of.
- Intel i5-8400
- Liquid CPU Cooler Cooler Master - MasterLiquid Lite 120
- 8GB DDR4-2666 G.Skill - Ripjaws V Series
- M.2 SSD 128GB Samsung - PM961
- Nvidia GTX 1050 2GB (MSI)
- Micro ATX Gigabyte - H310M
- 450W PSU EVGA 80+ Bronze Certified ATX Power Supply
- MicroATX Mini Tower Case Rosewill - FBM-01
Optional HDD Suggestion:
Foremost, typically the most expensive part of a high-end custom build tends to be its GPU, where the latest 1080 and 1070 GPUs cost about your entire budget alone. In order to reduce cost I decided to recommend you a GTX 1050 which should be able to render 4K at 60 fps, I don't believe the C++ OpenCV libraries are terribly inefficient so you should be good there.
The i5-8400 is on par with the i7-6700K in terms of performance with the exception of floating point calculations where it lags behind a little bit.
The PM 961 outperforms the 2.5" Samsung 860 EVO with a whopping 1496 MB/s seq read and 722 MB/s seq write. If you're not familiar with them, the Samsung EVO's are well known for being one the best valued SSDs and can pack quite a punch. I have an 840 EVO and can attest to its performance.
I had to skimp on the RAM to try and save money. I did however try to find RAM with the lowest CAS latency.
In order to save money on the Motherboard, I had to use a motherboard that only supports up to 32 GB of RAM despite the i5-8400 supporting up to 64 GB of RAM split over 2 slots. Also the cheap-o case I recommended doesn't have front panel USB 3.0 ports.
In case you missed it, here is the PC Part Picker page for this build which will help you automatically track the best place to buy each part for your build.