Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

Thursday, November 14, 2019

Test Linux distros before downloading and installing


If you're completely new to Linux or if you've been using it a while and considering seeing what other Linux distros might offer compared to your current one then there is a great service called DistroTest.

DistroTest has hundreds of Linux distros that you can boot up and test directly from the website. It allows you to run a VM of the selected Linux distro live from the website. The performance isn't great but it's enough to get an idea of what the default setup of any given distro is like. You can look at the software that is included, experiment and do what you like with any of hundreds of different distros.

So, if you're looking to test before diving in as a new user, or if you're experienced and want to just look at how another distro is configured then give it a look.

https://distrotest.net/

Wednesday, June 25, 2014

Coming Soon : DIY Dirt Cheap Lightning and Sound Camera Trigger


I've ordered some electronics with the intention of building a DIY lightning and sound trigger unit for my DSLR cameras.

The goal is to make a small unit which can be attached to various cameras easily in order to trigger the shutter if the unit detects lightning or sound.

This will mean that the camera will be able to be set up to attempt to capture lightning bolts, or bullets exiting the barrel of a gun, or balloons popping or even allowing a second camera to shoot the same shot from a different angle by being triggered from the flash from the primary shot.

There are a few possibilities where this device could help capture something that can be tricky to manage otherwise.

My investment so far in less than $25 for the electronics. I still need to look at some materials to make an enclosure for it, but I aim to keep the entire build at well under $50.

When the gear I've ordered has arrived I will be putting together a short series of tutorials on building and testing the unit so anyone else will be able to follow along and build their own. (I'm not listing the materials yet as I am not 100% sure I've got everything I needed yet. They will be revealed soon)

I'm also thinking ahead and planning a stage 2 for this project where I will be adding on to my device an adjustable intervalometer and maybe some other sensors I think might be able to be utilised to help capture some interesting photos.

Stay tuned.

Monday, June 23, 2014

How to create a time lapse video with free software


What is a time lapse video?
It is a video created (most commonly) from a series of photographs taken over a period of time that speeds up the time, essentially making everything run in high speed. As such several hours worth of photographs can be condensed down into several minutes of video.

It is very effective for watching the changes of light or the movement of people and objects over the course of hours, days, weeks, months and sometimes even years. Some examples have been time lapse videos that cover the entire construction of buildings or the change in a landscape over a year highlighting the changes of season.

It can also be used to view a high speed video of food decomposing or crayons melting. I'm sure you get the idea.

Here is a short time lapse I did some time ago using webcam footage. Please note: This was done prior to me working out the method in this tutorial, using low quality webcam images. See the end for examples created using this method.


Getting starting


In order to effectively create a time lapse video you will need a camera. Really any camera will do, but unless it is capable of being controlled by a remote (DSLR) or has time lapse features built in already (GoPro) then it will be a very manual process and hard to manage.

This is because you need hundreds of photos over a period of time. Standing with a compact camera and pushing the shutter button every 5 seconds for 3 hours isn't really my idea of fun. Not only that but it also opens it up to wobble and distorsions in the images which will affect the quality of the video.

So, ideally you want a GoPro or a DSLR with an intervalometer. ( A remote capable of opening the shutter repeatedly with a set interval). The manual control of the DSLR will also help with exposing the photo correctly.

Find a composition


Find a place suitable for capturing an interesting time lapse. It may be the crowds of people walking through a city, or perhaps a sunrise or sunset. I will leave that part to you to determine. Once you've found your composition, take photos.... lots of them. The more photos you have, the longer the video clip will be.

Taking the shots


The interval you use between shots is up to you but as a general rule, the quicker/shorter the interval the more smooth the end result will be as there is less time passing between each capture. The longer the interval the more jumpy the end result will be as there is a larger period of time passing between each image.

Having said that. While an interval of a couple of seconds will be very smooth, it will also be the slowest in terms of time advancing in the end result. You might compress 2 hours down to a 20 seconds for example. Whereas an interval of 15 seconds between shots might result in the 2 hours of images compressing down to 5 seconds.*

* I just made those figures up. I'm too lazy to calculate it. It's to try and explain the concept.

Image quality


Image quality is really up to you. If you have the gear, and the time or you want the best possible outcome then I suggest shooting RAW. If you can only do JPEG then that's going to be okay as well.

I am not going to get into the actual procedure of batch processing hundreds or thousands of images but suffice to say it is possible to make some adjustments to the first image and apply those same adjustments to the rest of the sequence using software like Raw Therapee.

(Feel free to comment below and let me know if you are interested in a tutorial on Batch Image Processing using RAW Therapee)

Import the files


I have just copied the time lapse images from the camera into a folder for the video and then into an images subfolder. (In my case I was shooting RAW and did a quick batch process so my final images are in a converted folder as we need them as JPEG to encode to video.)



To make it easy for the encoding software it is ideal to have the images in a numbered sequence. This can be done by selecting all the images (Ctrl + A) then right clicking the first image and choosing rename. Call it timelapse or whatever you want. The operating system will then rename the images in a numbered sequence as below.



Making the video

Here is where the magic happens, but first, if you don't have it already, go and download VirtualDub. It is a small download for a very powerful application.


When you first run the VirtualDub application you will see a dull gray screen.



We will start by loading our image sequence by clicking File -> Open Video File or Ctrl+O
Navigate to the directory containing your image sequence from earlier. Select the first image of the sequence which should end with the number 1 and make sure Automatically load linked segments is checked.


Once loaded you will (depending on size of images) see part of the image in the empty gray area. Something like this.


If you Right Click the image and select 25% (or whatever works) for your screen size you should notice it will resize to be more suitable. You can go ahead and do the same on the right hand side of the screen as well.


If you haven't guessed it already we have panels for input and output.

Next, we want to add some filters and adjust the frame rate of the video to be suitable.

The first filter we want to add is the Resize filter which will enable us to specify the size of the video output. For a high definition video you could choose 1920 x 1080

Click Video -> Filters (or Ctrl + F)
Click Add
Select the resize filter and add it
In the options dialog you can set the size of the output video. I recommend setting the aspect ratio as per the screenshot below to 16:9 and then you can set the absolute size about and it will remain constrained to that aspect ratio.



Secondly I would suggest downloading the MSU Deflicker filter from here. It can be installed by unzipping it into the plugins directory under your VirtualDub directory. (It does require VirtualDub to be restarted)

If you choose to do this it can help compensate from flickering that can be caused by slightly different exposures from image to image. Well worth doing, especially if your camera was in something other than full manual mode.



Add it with the default settings to begin with. I've found them to be quite suitable for most cases.

You should have noticed after the resize filter, the change in the output panel on the main screen. However, there is another thing we need to do before we encode the video.

We need to set the frame rate. 25 frames per second is a good starting point. I recommend starting there and if you don't like the output after that you can adjust it up or down to suit the look you feel is best.

Select Video -> Frame Rate or (Ctrl+R)


Leave the bottom half of the framerate options as they are, just select Change frame rate to (fps):  and set your desired frame rate.

Now, we are almost done. You should have something that looks a bit like this. (Obviously with your images, not mine)


Before we go ahead and encode the video we are going to want to setup some sort of compression, we do this by selecting a codec to use for the video. Select Video -> Compression or (Ctrl + P)

The dialog that opens will list the various codecs available on your system that VirtualDub is able to use. I personally have been using Xvid (which, if not in the list can be downloaded here)

You can use whichever suits you best.


For Xvid you can adjust the options to keep the file size reasonable without losing too much quality to the compression. The screenshot above shows the settings I last used on the videos I will have at the end.

Alright... still with me?

The final step is to encode the video. To do this we select File -> Save as AVI or (F7)

Choose a location to save the video to and give it a name.

Then wait for the encoding to finish and once it has, you can open the folder where you saved it and play the video to view the final result.

Here is an example of a couple of short time lapse clips I created using this method described above. In these videos the photographs were taken using my Nikon D5100 DSLR in RAW mode and batch processed with a preset from Raw Therapee prior to then creating the time lapse using VirtualDub.



Hope this helps get you started making time lapse videos. If you wan't, feel free to comment below with a link to your video.

Monday, June 16, 2014

Code a Simple Day/Night Cycle Part 1


Not all games require a day night cycle system and plenty would not benefit from having one, but it is a staple requirement of adventure and role playing games. It seems like a complex thing at first consideration but at least for a basic system it is not really that hard. When you start with a basic system like this, it becomes easier then to customise and add features to make your game stand out.

My aim in this tutorial is to look at the code required, but in order to do so I will also need to touch on the setup of the elements in the game engine to make this happen. I will assume you have at least some knowledge of coding and the engine you plan to use so I am going to use pseudo-code here. I will leave it to you to adapt it to the language and engine of your choice.

Setting up the sun


Before we get into the code, the very simple day night cycle here will require a little setup in your game engine. Some (but not all) of the game engines I have experimented with seem to allow you to simply rotate a directional light, and they handle the billboarding of the sun moving through the sky. In some others, or if coding one from scratch, you may need to consider a setup such as this.

Create an invisible scene node as the sunController and position it at approx the center of your map.
Create a sceneNode as a child of the sunController and position it a good distance away from the sunController, attach the sun directional light to this node and set its direction to be facing the sunController. I will leave you to work out billboards, etc.

Now, as you rotate the sunController around the desired axis, the sun light will move around as well. You should be able to preview the effect and fine tune it by manually setting the rotation of the sunController and viewing what it does with the light.


Code the sun

Now, lets get to the bit you're really interested in. Psuedo-code. Well, actually, you'd probably prefer real code, but then you would just copy and not really learn much.

Lets say we want our data about the time to be available to other parts of our game (such as when saving a game). We will want to create a class that can be accessed to gather that information. This could be useful not just for saving a players game but to provide other dynamic features such as moving clocks or events that are triggered at certain times.

class GameTime {
.....
}

Now, we will need to have some variables to store the time information we want.

public float currentHour;       // The current hour of the game day
public int currentDay;        // The current day of the week
public int currentWeek;     // The current week of the month
public int currentMonth;    // The current month of the year
public int currentYear;       // The current year

Now for some basic variables that will help control our sun. This includes how long 1 game day will last and uses that to calculate some other required data.

// 1 in game day will take 30 real minutes (30m * 60s = 1800s)
private int dayLengthInSeconds = 1800;

// Calculate how many degrees the sun needs to move through the sky per second
private float sunRotationDegPerSecond = 360f / dayLengthInSeconds;

// How many degrees of sun rotation per game hour (assuming 24 hour days)
float degreesPerHour = 360f / 24;

// current rotation of the sun
private float sunRot = 0;

// GameObject for our sunController (or Sun as required)
public GameObject sunController;

// Constructor
public function GameTime() {

// Set the GameObject
sunController = EngineSpecificGetEntityFunctionCallHere();

// calculate starting position based on time
sunRot = currentHour * degreesPerHour;

// Set the initial rotation around specified axis (z)
// How this is done will vary based on the engine. 
// Again, this is psuedo-code not to be copied verbatim
sunController.rotation.z = sunRot;
}

// The update function will be called every frame
public function Update(float frameDelta) {

// Check if the sun object exists
if(sunController != null) {

// Reset to 0 if require
if(sunRot > 360f) {
sunRot = 0;
currentDay++;
}

// Calculate rest of time
if(currentDay > 7) { //assuming 7 day weeks
currentWeek++;
currentDay = 1;
}

if(currentWeek > 4) { // assuming 4 weeks to a month
currentMonth++;
currentWeek = 1;
}

if(currentMonth > 12) { // assuming 12 months in a year
currentYear++;
currentMonth = 1;
}


// Update the suns rotation by taking the degreesPerSecond and 
// multiplying by the frameDelta to calculate the degrees for 
// that part of that second.
sunRot += degreesPerSecond * frameDelta;

// Set the rotation around specified axis (z)
// How this is done will vary based on the engine. 
// Again, this is psuedo-code not to be copied verbatim 
sunController.rotation.z = sunRot;

// Recalculate currentHour

currentHour = sunRot / degreesPerHour;

}

}


Basically what we are doing here is determining how long we want an in game day to last in real time and then calculating how much to move the sun so that it does a full 360 degree rotation within that time period.

30 minutes might be too short or too long for your game, it is completely configurable. You could set it to quite a short period in order to test the functionality quickly. However, if you intent to lower the number of seconds a day lasts below 360 you will likely need to make some adjustments in the code to compensate for that.

By taking the number of degrees we need to rotate per second and multiplying that by our frameDelta we get the correct degrees of rotation for that frame which is generally a fraction of a second.

In the constructor we set the initial rotation based on the currentHours, so this could be preset to 6 to have the sun start at sunrise, 18 for sundown, 12 for midday, etc.

It may take some tweaking to get correct, but with a bit of experimentation you should have a sun tracking through the sky and giving you 12 hours of sunlight and 12 hours of darkness.

Good work.

This is only part 1 of the overall day/night cycle solution however. In part 2 we will look at the blending of a skybox or skydome to allow our map to have a black sky at night, a bright orange glow at sunrise/sunset and a sky blue during the day.

Stay tuned for part 2 coming soon.

P.S. If you would really like to see code to suit Unity 3d or NeoAxis please comment below and I will consider providing it. Although the implementation might be slightly different to suit the specifics of those Engines.