OpenCV – Select, Capture And Save Camera Feed

EyeLine Video Surveillance Software

This Video Shows how to Capture and save the camera feed using OpenCV. It also Details how to select different cameras.

As always, To compare your scripts, if you have issues, I have included notes and the completed scripts at the bottom of the page which you can view or download from my Google Drive. The scripts also have notes as comments which appear after a #.

Remember if you can’t view fullscreen, you can right click the ‘youtube’ icon in the bottom right and select ‘view on Youtube.com’

Notes

The supplementary information can be found on the official OpenCV website https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_gui/py_video_display/py_video_display.html

The # is used in python to comment code after it on the same line. The importance of using this to comment code is the compiler ignores this when running the code but anyone coming later to work with your code can see why you have used the code you have or any notes you may have put in to modify it.

Some people say that “””comments””” is ok for multi line comments but this is wrong as it can get you into trouble. This is because it is a ‘docstring’ which is treated slightly differently. more info on ‘docstrings’ and their rules can be found here https://www.python.org/dev/peps/pep-0257/ but it is a slightly more advanced topic that you should save for later. Just remember only use a ‘#’ for comments on each line.

Download Links

Github OpenCV repository https://github.com/opencv/opencv/

Completed Scripts

Below is the link to the Google Drive repository for this lesson. You can either view online or download.

https://drive.google.com/drive/folders/190fHm-aJZfLM41rWjFPHxJycKteIq5zW?usp=sharing

OpenCV – Read and Write Images

Xara Web Designer

This Video Shows how to Open, Read and Write images using OpenCV. In the last post, I mentioned he flicks back to using Pycharm IDE for code editing so definitely go to https://www.jetbrains.com/pycharm/ and download / install the pycharm IDE which at present is free in community edition.

To compare your scripts, if you have issues, I have included notes and the completed scripts at the bottom of the page which you can view or download from my Google Drive.

Remember if you can’t view fullscreen, you can right click the ‘youtube’ icon in the bottom right and select ‘view on Youtube.com’

Notes

When copying lena.jpg, depending how your file structure has formed, when running the script, you may get an error. Try right clicking on the ‘venv’ folder and copy the image there or drag and drop from the main folder location. The script should now run and display the ‘lena.jpg’ image.

Keyboard key values can be found at http://www.asciitable.com/. It looks like below. Use the key ‘DEC’ column value. The key description is in red in the last column.

Ascii Table
http://www.asciitable.com

Download Links

You can download Pycharm from https://www.jetbrains.com/pycharm/

You do not need to but if you want to download microsofts awesome free code editor Visual Studio Code, This is the link https://code.visualstudio.com/ but all of the lessons are completed in Pycharm which I would advise using to follow along and then convert to VS code later when you are experienced.

Github OpenCV repository https://github.com/opencv/opencv/

Completed Scripts

So I hit another WordPress file type issue and can’t share script files so below is the link to the Google Drive repository for this lesson. You can either view online or download.

https://drive.google.com/drive/folders/190fHm-aJZfLM41rWjFPHxJycKteIq5zW?usp=sharing

Opening Downloaded Files

Sometimes your browser will not allow you to open downloaded files from the bottom of the browser, especialy if they are .zip files but you can either use the drop down arrow next to the downloaded file at the bottom of your browser and select ‘open in explorer’ or go to your ‘Downloads’ folder and find it there. Again if it is a .zip file then you can right click it and select ‘Extract All’ which will create a larger size folder version of the zip file. This will work now.

OpenCV – Installing on Windows

Xara Web Designer

If you are using a Windows Operating system i.e. Windows 10 then this is the video showing you how to install OpenCV which is crucial to learning. If however you are using a Linux Ubuntu system then please look at this video https://youtu.be/cGmGOi2kkJ4

The topics covered in this video are also useful for learning background features in Windows 10.

Please see the links and text below to follow along.

Download Links

You can download Python from https://www.python.org/

You do not need to but if you want to download microsofts awesome free code editor Visual Studio Code, This is the link but the rest of the lessons are completed in Pycharm which I would advise using to follow along and then convert to VS code later when you are experienced. https://code.visualstudio.com/

Commands for command prompt

  • python –version
  • pip –version
  • pip install opencv-python
  • python
  • import cv2
  • cv2.__version__

Opening Downloaded Files

Sometimes your browser will not allow you to open downloaded files from the bottom of the browser, especialy if they are .zip files but you can either use the drop down arrow next to the downloaded file at the bottom of your browser and select ‘open in explorer’ or go to your ‘Downloads’ folder and find it there. Again if it is a .zip file then you can right click it and select ‘Extract All’ which will create a larger size folder version of the zip file. This will work now.

Command Prompt

Windows 10 is what they call ‘evergreen’ which in laymans terms means it is always updating and changing. This is normally behind the scenes stuff but does affect how the menus work. At the time of writing, to get the command prompt in the method shown on the video, you have to

  • Right Click the Windows Icon (Menu Icon)
  • Select ‘Run’
  • Type ‘cmd’ in the box
  • click ‘OK’ or press ‘Enter’

Screen Record with VLC Media Player

Screen Record with VLC Media Player video is now live and can be viewed on you tube or below.

This is an awesome feature of VLC media player as it gives the ability to record your desktop and everything that is displayed on it – nudge nudge wink wink – without having to go to great expense of proprietary software or the restrictions of Windows 10 Game Bar.

Please watch the video and leave comments if this was useful to you and you want to see more like this. Don’t forget share PLEASE.

 

 

UGEE M708 GRAPHICS TABLET

I always wanted an all singing and dancing Wacom Graphics tablet for my 3D modelling but the thought of paying similar to a new laptop got me thinking about the Lenovo Yoga series of laptop, with the foldable screen hinge, as you can see and interact directly with your model or digital art.

I wanted to also make sure it was what I wanted so thought ‘Go Cheap import to test before investing huge wedge’ and found this UGEE M708 Graphics Tablet for £60 2 years back and it is still going well. I have the older battery powered pen version but the one from amazon below has a self recharging pen which is cool, having said that the battery normally lasts me 2 months which is ok for a single AAA battery. I will also mention there are others like XP PEN which are cheaper still and look the same but that’s all I can say.

Click Here to See the UGEE M708 on Amazon

Ok so after wanting one of these for ages, I now have it. Its A4 ish paper size so quite large so I should be good to go. I mean, I can use Blender and 3DS with a mouse, right, and this was supposed to be more natural. That’s the problem, I have no natural art skill so thats my first thing to say – you can have all the tools but don’t expect to be pulling a Van Gogh in 5 minutes. Now I am glad I only spent £60 and not £400 on its equivalent Wacom.

Ok so I never give up and slowly started to see what I can do with simple spray can art which was great and I managed to make some beautiful coloured boxes in Blender. Without knowing I slowly started replacing my mouse with the pad and pen, for normal computer use, as you can do all 2 button mouse operations with it while not having the Mouse click RSI as it effectively makes a normal computer gain the benefit of a Tablet at a fraction of the cost.

img_20190614_201452.jpg

IMG_20190614_201129

The Tablet itself is easy to use as the pad corners (white Brackets) are mapped to your screen so there is no dragging and scrolling like on the old tablets you just hover the pen over where you want the cursor to appear on the screen and when it is close enough to the tablet, about 15mm, sure enough the cursor appears on the screen. Sure it would be great to have one of the £700+ tablets with a screen underneath but then we go back to my original buying a Lenovo Yoga. Amazon also have them Lenovo Yoga 720

The Following Video shows how easy it is to use with Blender in Plug and Play. I am only using the Pen here but there are 6 more configurable buttons that can be tailored as you desire but you will have to load the Driver Disk (supplied) to configure them. You can also download the driver from the UGEE website if you do not have a Disk Drive.

As you can see it is very easy to use and all of this via USB plug and play. Talking of which, the pen is compatible with windows 10 ink so is customisable in Windows 10 too.

In short it is a cheap and cheerful tablet that can give you an extra few years out of your old PC when you want to expand your skills into 3D modelling / Paint / Photo Editing / Drawing / Handwriting or even just want to add some signature functions.

Ok the nitty gritty:

  • Active Area – 10″ x 6″
  • Resolution – 5080 LPI
  • Report Rate – 230 RPS
  • Accuracy – +or- 0.01″
  • Pressure sensitivity – 2048 Levels
  • Connection – USB

 

BIM – The OpenSource method

Ok so today is all about creating a Virtual World without spending too much money although I would always advise donating and supporting the OpenSource projects because we all benefit from them and they tend to have great imaginative and ethical origins which remain strong throughout the lifecycle of the project. Throughout this post I have added the links to the websites which will open in new tabs, if clicked, and you will see that they all have ethics and a dream at their core.

So to Generate the Virtual World / BIM solution – What do we need? (aside from a little training – all documentation is available on the websites)

Domain (£20 per year) – to have a web address like http://www.vulcansrealm.com, you need to buy it and register it on a Domain Name Service. Its all done for you and is as simple as buying a computer on Amazon.

This can all be acquired by Hostinger but you need to plan what you want and if this starts to blow your mind, You can skip the cloud service section and hire that resource from Hostinger for a monthly fee but it is good to know how to do it. (you can skip 7 paragraphs down to QGIS if you go with this option so there are benefits)

The Link Below May Earn Commission

Hostinger

Next we need some serious Hardware which can be upgraded slowly as required. A cloud network allows us to do this brilliantly and to surprisingly use low cost equipment to do this. So for instance you may want to spend a £1000 on a nice refurbished all in one server 64bit, 16GB RAM, 2TB disk with dual network cards — but this is not a traditional server service – its a cloud service and maybe you are starting from more humble origins

So as a cloud service, in the not too distant future, we will need a cloud resource handler. This is, In Laymans speak, what makes all the servers talk and co-operate together seemlessly. There is no reason why we can’t incorporate that from the start and use OPENSTACK and now we can change our hardware requirements to something more humble like a Raspberry Pi3B+  and I believe this is the way.

You can start with 1 and as you develop you can slowly add them till you have a small  cluster of raspberry pi3B+’s. I say small, maybe you will end up with a large cluster in multiple Global locations or Hubs.

I need to test if you can just pull one memory card out of one RPI3B+ and insert into another so you can have your little RPI3B+ cloud service easily maintainable if a Component fails. I have no reason to doubt this could be the case as RPI3B+’s don’t appear to have a TPM (Trusted Platform Module) chip and use open source Operating systems which are not intended to prevent sharing. This is one of the aspects why you can’t pull a hard drive from one windows 10 pc and put it in another.

Ok so what software do we need to make my Raspberry Pi3B+ into a cloud server, Simply put UBUNTU server (free) and NEXTCLOUD which is free for home use and companies with upto 50 employees. When you become a big boy commercial, you will have a small support package to buy but if you have more than 50 employees, a few thousand pounds is merely a round of drinks. I should add, I am happy to tag along to an open bar if anyone is offering.

So we are starting small which means we probably do not have a fixed IP address on our internet providers connection and running this from a home Internet connection like SKY, which changes the IP address each time it connects or after a period of time, so we will need to have whats called a DDNS handler. Once your device is registered on this service, all traffic that was routed to your old IP address is routed to the new IP address automatically in real time. For more information Google DDNS but a service with noip.com will typically cost £25 a year – hold on why not the free personal use option with other providers, they are for personal use and they will know what you are upto. Its the equivalent of being caught with your hand in someones wallet and saying I didn’t know. If you believe in KARMA (not the drone) you will stay above board. you can also get a whole host of other services and even your domain name from noip.com too.

Ok so we have an always connected managed server(s) in our cloud network, we need an email service to be contactable with our users and for security reasons. For this we can use hMail server (free) or alternatively you can have noip.com provide this for you but we are going for less reliance on others so lets have hMail.

To handle all the Geospatial Information we can Incorporate QGIS server or other OSGEO server products(free) so we now have mapping. Its building up isn’t it.

So we really want to get to the fun stuff and walk around in virtual space but we need to identify with the technology and with this being industrial related, lets use OpenMaint for asset management and data maintenance.

One of the beautifull things with Cloud computing is Virtual Machines, they absolutely anhialate bandwidth but NextCloud supports them and it simplifies the process so for those updating and creating the Virtual Space. Lets Install XAMP vm server running apache. php and mySQL.

We can now load,submit and run pointcloud files using POTREE point cloud viewer (free)(see next cloud docs and using docker)

For converting point clouds into mesh to be modified as models for the Virtual World physics engines, we can run MESHLAB running on a vm instance (free)

We can process the models once converted using BLENDER 2.8 on a vm instance (free) (requires good graphics upgrade, suggest a good pc and transfer the data after processing in a separate render farm but not from the realms of do-able at low cost)

So we have a dumb Virtual World now. Lets add Physics and gamifi using ARMORY3D(free) (requires BLENDER 2.8 but this is packaged with the download)

So we have our world but how do we make it accesible. lets use AGONES (requires kubernetes) or GAMINGANYWHERE(requires windows OS) for online realtime hosted games/simulations (free).

Hold on – Kubernetes why not just use this to manage the cloud instead of OPENSTACK. It is more a preference to make them work together. In laymans terms Kubernetes is the operations manager of container ships where Openstack is the shipping company. Yes the operations manager will perform the work like the company but the company also has a finance department, customer liason, Welfare, Sales etc.

We should now have an online fully interactive cloud hosted virtual world for nearly no money, reliable and infinitely upgradeable.

So What about That Pint you mentioned…………..