I’ve seen it before, a customer deletes a file and then needs it restored.
Normally a challenging request, but under special circumstances a process may have the file opened.
While showing my son some fun and exciting Linux security scenarios, I recalled all those times I was able to recover data from the /proc (in memory) filesystem. In order to visualize this scenario I threw together a small Dockerfile and had him poke around:
This weekend I took a bit of time to read up on OpenCV(Open Source Computer Vision Library), I wanted to capture images of Magic the Gathering cards, then identify them using a Python library called ImageHash.
Below is a demonstration of what I was able to accomplish in about 2 days of research and hacking:
I’ll try and break down the steps and image manipulation functions I used to achieve this.
1. Capturing Stream from Webcam
Capturing the video stream, then displaying it on screen, is quite simple. What I did was create an endless loop where I capture a single frame, then display that frame. This loop will complete when the q key is pressed.
cap = cv2.VideoCapture(0)
ret, frame = cap.read()
if cv2.waitKey(1) == ord('q'):
For demonstration I’m going to show you a snapshot of the stream through this process:
Here is where I got lazy and decided to just hack it together.
If you notice in the above image, there is a contour for the entire frame and the next largest contour is our card’s edges. I decided for the time being to hard code our card contour as the 2nd largest contour: