How to Prepare to Photograph the Total Lunar Eclipse on Jan.20 (Useful Tools & Website)

Hi there, I am an amateur photographer. Most of my photos are about stargazing and landscape. Checkout my photography gallery here (photography.songyaojiang.com). I would like to share with you some tips and useful tools that I used to prepare for photographing the lunar eclipse, which is coming soon on Jan. 20 2019.

Total Lunar Eclipse of 2000 July 16 (Lahaina, Maui)
http://www.mreclipse.com

Preparing to photograph a lunar eclipse requires much more knowledge and research efforts than preparing to watch a moon eclipse. When you decide to watch a moon eclipse, basically what you need to do is just going outside at looking for the moon in the sky.

Photographing a lunar eclipse, however, requires much more detailed knowledge on the direction, altitude and time of every phases during the moon eclipse. You need to plan ahead, pick a location, set up your camera, pointing your camera to the correction direction and wait for it to happen. Besides, you need to carefully set up a timer and adjust your camera exposure (ISO speed, shutter speed and aperture) during the entire moon eclipse. If you want to photograph the whole period of lunar eclipse, you may have to continue photographing for at least 4 hours, which may be an extreme task especially in winter season.

Preparing for the Eclipse
Fred Espenak prepares for the eclipse from lanai of his hotel room in Lahaina, Maui.
http://www.mreclipse.com

Here is a brief summary of what you need to plan in order to photograph a total lunar eclipse properly.

  1. Date and Time.
  2. Direction and Altitude.
  3. Weather Forecast.
  4. Location.
  5. Equipment.
  6. Photography Tips.

TimeAndDate.com

TimeAndDate is a useful website to check date and time, direction and altitude information at the same time. It provide you a location specific information of special astronomy events such as meteor shower and solar/lunar eclipses, which serve as a great solution to the requirement 1 and 2. Here is an example of the lunar eclipse event in Boston, MA
https://www.timeanddate.com/eclipse/in/usa/boston

Time, phase, events, direction and altitude of the lunar eclipse on Jan. 20 for Boston, MA
http://www.timeanddate.com

Clear Sky Chart

Clear Sky Chart is the astronomers forecast. “It shows at a glance when, in the next 48 hours, we might expect clear and dark skies for one specific observing site.” It provide hourly rich information about all the factors which affect the astronomy seeing, including cloud cover, darkness, air transparency, wind, temperature and humidity. This website can serve as a accurate short-term forecast tool just before your photographing activity. Here’s an example of the Clear Sky Chart for Boston.
http://www.cleardarksky.com/c/Bostonkey.html?1

Clear Sky Chart for Boston, MA
http://www.cleardarksky.com

Accurate Weather

Accurate weather provides a detailed and professional weather forecast in real time, short term and long term, including a great bunch of extra information. I use this website and its iOS app together with the Clear Sky Chart to check out the weather in my target location. https://www.accuweather.com/en/us/boston-ma/02108/weather-forecast/348735

Weather forecast for Boston, MA
http://www.accuweather.com

Weather Map

Besides short-term and long-term weather forecast, a basic need is to find a clear sky around your location when your location is suffering a bad weather. Here is a recently found solution provide by weather-forecast.com. It provides a weather map that shows you a interactive map which visualize of the weather around your states. Here is an example of the weather map in MA (Link). You can slide the bar at the bottom to move forward the time by hour, at a maximum of 10 days ahead. Using the search box at the top right corner of the page, you can easily find the weather map of your state. According to the weather map, you can choose a location to visit, in order to obtain a clear sky to photograph the lunar eclipse.

Interactive weather map for Massachusetts
http://www.weather-forecast.com

Photography Tips

Photographing a lunar eclipse requires a great bunch of basic photography skills and experience. The easiest way is to read a professional’s blog. Checkout this great tutorial about how to photograph a lunar eclipse. It covers how to set up your camera and many example photos with descriptions about how they shot those photos.

2000 Total Eclipse Over Maui 
The Multiple Exposure technique was used during the total lunar eclipse of 2000 July 16 from Maui. A Nikon 8008 in multiple exposure mode was used to capture the entire eclipse on one frame of film. 
The basic exposure of 1/125 second at f/5.6 was increased to 1/8 second within 15 minutes of totality and then set to 4 seconds throughout totality. A second exposure (metered) captures morning twilight and silhouetted palm trees. 
Nikon 8008, Nikkor 35mm f/5.6 Kodak Royal Gold 100: 1/125 to 1/8 on (partial phases), 4 seconds (totality) 
http://www.mreclipse.com/LEphoto/LEphoto.html
Advertisements

[PyTorch] Getting Started with PyTorch

Introduction:

PyTorch is a very powerful deep learning framework in python which has a strong GPU acceleration support. Previously, Torch 7 a a good framework based on lua, which is a language few of us like to use. PyTorch is based on Python which has all advantages of the Python such as extendability and easy-to-use feature. It has become popular in many deep learning research topics and well used by many famous research group.

Environment:

System: Ubuntu 16.04 LTS

Python: Anaconda Python 3.5

CUDA Version: 8.0

Installation:

HomePage: pytorch.org

Install command:


conda install pytorch torchvision -c pytorch

Good Example Code:

Generative models:

https://github.com/wiseodd/generative-models

This GitHub repository is a collection of many popular generative models written in PyTorch. They simplify the models and remain only the key parts such as model structure, loss function and training procedure.

CycleGAN and pix2pix:

https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix

This GitHub repository looks nice and extendable. They build nice base model and dataloader which could be modified to your own model. Moreover, they use visdom created by Facebook (GitHub) to visualize the training results.

 

[Ubuntu] Install Dual Boot System of Windows 10 and Ubuntu 16.04 with Nvidia 1080Ti

Although I have installed Ubuntu for many times, this is the first time that I face so many weird issues such as black screen, no response, grub disappear. Therefore, I write the solution down for future reference.

System Specs:

CPU: Intel Core i7-7700K

GPU: Nvidia GTX 1080 Ti

Motherboard: Asus Z270 Prime

Wi-fi Adaptor: Netgear A6210

Description:

I burn Windows 10 and Ubuntu 16.04 into two USB flash drives. First I install Windows using UEFI successfully. Then I try to boot from Ubuntu USB drive using UEFI. A grub menu with several options including “Try Ubuntu” and “Install Ubuntu” shows. However which option I choose, it will be a black screen and I cannot go through.

Causes:

By doing some research and keep trying for many times, I finally find that it is graphic driver compatibility issue. My 1080 Ti is too new for Ubuntu 16.04 that it doesn’t support the graphic card. That’s why there always be a black screen.

Solution:

When booting, get into BIOS settings and turn off Fast Boot and Secure Boot.

To turn off secure boot on Asus motherboard, first go into security keys and save all four keys into USB drive. Then delete PK key and you will see that the secure boot option is turned off.

Boot from Ubuntu USB drive. In Grub menu, move cursor to Install Ubuntu and press ‘e’ to edit. Add one key word ‘nomodeset’ before the string”quiet splash”. This will turn off graphic card drivers. Then press F10 to continue installing and you will see the ubuntu logo appears.

Continue install Ubuntu 16.04.

After successfully install Ubuntu, when rebooting, in Grub menu, move cursor to “Ubuntu”, then press ‘e’ to edit. Same as previous step, add ‘nomodeset’ in the line of “Linux”. Press F10 to boot. Otherwise, you will see a black screen instead of going into your system.

In your system, make sure the internet is connected. In my case, I am using Wi-fi Adaptor Netgear A6210 that Ubuntu doesn’t have a default driver.

git clone https://github.com/jurobystricky/Netgear-A6210
cd Netgear-A6210
make
sudo make install
sudo service network-manager restart

This will enable your Wi-Fi adaptor.

To install drivers for GTX 1080 Ti, follow the code below:

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-381

Reboot your computer and you can go into Ubuntu without any problem. To verify the driver version, type nvidia-smi in your terminal and make sure the driver version part of the output is as you expected.

Screenshot from 2017-09-03 12-25-07

Reference Link

Installing and Updating GTX 1080 Ti Drivers / CUDA on Ubuntu

 

 

 

 

 

[Torch7] Getting Started with Torch 7

I am reading paper about deep learning based image processing and some of them are written in Torch 7, that’s why I start to learn Torch which I think will benefit my future study in deep learning.

What is Torch?

Torch is a scientific computing framework with wide support for machine learning algorithms that puts GPUs first. It is easy to use and efficient, thanks to an easy and fast scripting language, LuaJIT, and an underlying C/CUDA implementation.

A summary of core features:

  • a powerful N-dimensional array
  • lots of routines for indexing, slicing, transposing, …
  • amazing interface to C, via LuaJIT
  • linear algebra routines
  • neural network, and energy-based models
  • numeric optimization routines
  • Fast and efficient GPU support
  • Embeddable, with ports to iOS and Android backends

Installation

Installation Guide in Mac and Ubuntu 12 +: Link

Sample Code

Image Colorization

Iizuka et al., Let there be Color!: Joint End-to-end Learning of Global and Local Image Priors for Automatic Image Colorization with Simultaneous Classification, SIGGRAPH 2016

Project Page     GitHub Code

Results:

ansel_colorado_1941.png

ansel_colorado_1941_colorized.jpg

[Rails] Getting started with Ruby on Rails

In order to interview some one to do full-stack web development for our company, I started to learn what is Rails (Ruby on Rails), what it does and how it’s different from Java EE. Here are some learning summary:

GitHub page: Here

Installation: Ubuntu14.04

Getting Started: English   Chinese

Current summary: I successfully installed and run my first Rails webpage. I still don’t know if it could replace Java for our web demo which uses a lot of C++ native library, which need to be further studied.

[Java] Glue Java and C++ Together Using SWIG (OpenCV Example)

Call native applications in Java

It happens that we want to use C++ code in Java application when we want to reuse our old C++ code, or when we would like to take advantages of the C++ executing speed, or when we don’t have the source code but only C++ libraries.

As we know, Java Native Interface (JNI) is a framework that enables Java code run on Java Virtual Machine (JVM) to call or to be called by native applications (e.g. C++ libraries). JNI Wiki

SWIG provides a relatively convenient way to wrap C++ libraries to be called by Java. It provides relatively easy method for class constructors and type mapping.

How to use SWIG (Ubuntu)

1. Download and install SWIG: Link

2. Write a interface file (*.h) which defines type mapping and included headers.

For SWIG, the only important C++ file is header files (*.h).  When we use SWIG to generate Java wrappers for C++ libraries, we only tell SWIG where to find the C++ header file instead of all the C++ source code.


%module example
%include "typemaps.i"
// for std::string type-maps
%include "std_string.i"
%typemap(jstype) cv::Mat "org.opencv.core.Mat"
%typemap(javain) cv::Mat "$javainput.getNativeObjAddr()"
%typemap(jtype) cv::Mat "long"
%typemap(jni) cv::Mat "jlong"
%typemap(in) cv::Mat {
    $1 = **(cv::Mat **)&$input;
}
%typemap(javaout) cv::Mat {
return new org.opencv.core.Mat($jnicall);
}
%{
    // include header to wrap
    #include "example.h"
    // include other dependencies headers
    #include <opencv2/opencv.hpp>
%}
// include header to wrap (relative path)
%include "../include/example.h" 

3. Use SWIG command to generate wrapper .cxx file and .java files.


swig -java -c++ -package com.your.domain.package.name example.h

4. Build generated .cxx files into c++ libraries.

5. Copy generated .java files to your package directory.

6. Load the C++ library


// direct load method by absolute path

System.load("absolute/path/to/library");

// search in library path with library name

System.loadLibrary("libraryname");

7. Use the library in Java as in C++ Done.

Observations

The most complicated part which should be paid good attention is the type mapping part. Some C++ native types (such as int, float and double) could be mapped by SWIG automatically. The other types cannot be mapped automatically will generate SWIGTYPE_p_cv__*.java file which indicates that there are errors when SWIG trying to type mapping such C++ types.

For C++ classes, private members are fine and will not be wrapped into Java. Therefore, their types need not to be handled by type mapping in SWIG. (which is excellent!)

Note that Java doesn’t support “pass by reference” (int&, double&) which is supported by C++. Java will pass all the parameters by creating new entities. Therefore when dealing with C++ code using “pass by reference”, we may want to write it into classes and store the variable in class public members to access their value.

If the C++ code is written nicely objective oriented (e.g. include dependencies headers only in .cpp file, store accessible variables as class public members, hide unuseful variables and functions as private members), the SWIG wrapping process will be much easier.

Reference

How to glue C++ and Java together

[Java] Threading and Concurrency

In one of my Java web service, I have a slow method in a class which read caffe model,do deep neural network application and then save the result.

However, the service is a real-time service that I don’t want the slow method to delay the others from executing. I have used some asynchronous method and concurrency tasks in C#. That’s why I search for concurrency method in Java. My objective is creating a new thread which runs the slow method as a task and save the result back to the original class.

example code:

 new Thread(new Runnable() {
    public void run() {
        //Do whatever
    }
}).start();

my code: (written with in a method)

new Thread(new Runnable() {
    public void run() {
        try {
            recommender = new Recommend(path);
            recommender.recommend(img_recommend, recommend_x, recommend_y, recommend_w, recommend_h);
            recommend_initialized = true;
            recommend_initializing = false;
            System.out.println("Initialize recommendation result successfully!");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}).start();

This method creates a new thread and a new runnable which contains the function you want to run asynchronously. This is exactly what I want.

The asynchronous code read a pre-trained caffe model and use it to recommend a result for an image which takes almost 10 second to execute on an Intel i7 desktop. By doing threading, these operation will no longer delay the others and the service runs smoothly.

Observe that the asynchronous code in this new thread could also call the class member variables and save results to class member variables, which is very good and convenient.

 

Some reference link:

Java 8 Concurrency Tutorial: Threads and Executors

How to asynchronously call a method in Java

[Caffe] Including Caffe in CMake Project

Including Caffe in your CMake project via find_package():

Reference: #1667


git clone git@github.com:BVLC/caffe.git.
cd caffe && mkdir cmake_build && cd cmake_build
cmake .. -DBUILD_SHARED_LIBS=ON
make -j 12

Then in your CMakeLists.txt of your project:


cmake_minimum_required(VERSION 2.8.8)

find_package(Caffe)
include_directories(${Caffe_INCLUDE_DIRS})
add_definitions(${Caffe_DEFINITIONS}) # ex. -DCPU_ONLY

add_executable(caffeinated_application main.cpp)
target_link_libraries(caffeinated_application ${Caffe_LIBRARIES})

If Caffe is not found by CMake, specify Caffe_DIR in your CMakeLists


set(Caffe_DIR /dir/to/your/caffe/cmake_build)

 

 

Create a free website or blog at WordPress.com.

Up ↑