I should be very careful working with Linux console. It seems it is able to do anything including destroying itself.
Anyway, it's lucky that we can recover the system by reinstalling it. Note that reinstalling the system will usually not ruin your home folder, which means you can keep all your files and settings.
Follow the step here to do a thorough re-installation:
https://help.ubuntu.com/community/UbuntuReinstallation
Monday, September 29, 2014
Friday, September 26, 2014
A Severe Accident with Ubuntu Kernel Update
I was being too young, sometimes naive to have the linux kernel updated since I believe it might resolve some of the bugs of the system.
The truth is: I'm wrong. After installing the latest kernel, which is 3.13.0-32-generic, I cannot boot into my system! It boots into the black screen instead.
It took me some time to resolve this, but it is actually very simple. In the grub menu, you can choose which kernel version you want to work with (in the advanced boot options). Choose the old one, and you will probably be able to have all the stuffs back.
What next? Remove all the latest kernels!
Do this:
sudo apt-get remove linux-image-3.13.0-32--generic
OK if you are unsure what kernel you have now use the following command:
cd /boot ls vmlinuz*
It will list all the kernels you installed.
The truth is: I'm wrong. After installing the latest kernel, which is 3.13.0-32-generic, I cannot boot into my system! It boots into the black screen instead.
It took me some time to resolve this, but it is actually very simple. In the grub menu, you can choose which kernel version you want to work with (in the advanced boot options). Choose the old one, and you will probably be able to have all the stuffs back.
What next? Remove all the latest kernels!
Do this:
sudo apt-get remove linux-image-3.13.0-32--generic
OK if you are unsure what kernel you have now use the following command:
cd /boot ls vmlinuz*
It will list all the kernels you installed.
Thursday, September 25, 2014
A Common Gitignore File
Tuesday, September 23, 2014
The Matlab Trick
Recently I had something tricky with Matlab.
[1 2 3]/[4 5 6]=0.4156 (this is equal to [1 2 3]*pinv([4 5 6]) )
[1 2 3]./[4 5 6]=[0.25 0.4 0.5]
These are two different things.
[1 2 3]/[4 5 6]=0.4156 (this is equal to [1 2 3]*pinv([4 5 6]) )
[1 2 3]./[4 5 6]=[0.25 0.4 0.5]
These are two different things.
Sunday, September 21, 2014
Open Multi-threaded Programming
Open Multi-threaded Programming:
#include <omp.h>
Linker settings: other linker options: -fopenmp
A toy example:
#include <omp.h>
Linker settings: other linker options: -fopenmp
A toy example:
#pragma omp parallel for
for (unsigned vel=0; vel<laser_points_all.size(); vel++)
{
#pragma omp critical
{
laser_in_camera.push_back(lasercam);
intersections.push_back(intersection);
iplane.push_back(std::pair<int,int>(vel,inter_plane));
}
}
Thursday, September 4, 2014
Format number and digit
If you want to format an integer to be six-digit by adding leading 0s, you can do that:
string GetSixDigitAccuracyName(int id)
{
ostringstream oss;
oss<<setw(6)<<setfill('0')<<id<<"_accuracy.txt";
return oss.str();
}
Wednesday, September 3, 2014
Parse Command Line
ParameterStereoSlic parseCommandline(int argc, char* argv[]) {
// Make command parser
cmdline::parser commandParser;
commandParser.add<std::string>("output", 'o', "output file", false, "");
commandParser.add<double>("factor", 'f', "disparity factor of input disparity image", false, 256.0);
commandParser.add<int>("superpixel", 's', "the number of superpixels", false, 2000);
commandParser.add("verbose", 'v', "verbose");
commandParser.add("help", 'h', "display this message");
commandParser.set_program_name("smoothfit");
commandParser.footer("imgL0 dispL0 motion");
// Parse command line
bool isCorrectCommandline = commandParser.parse(argc, argv);
// Check arguments
if (!isCorrectCommandline) {
std::cerr << commandParser.error() << std::endl;
}
if (!isCorrectCommandline || commandParser.exist("help") || commandParser.rest().size() < 3) {
std::cerr << commandParser.usage() << std::endl;
exit(1);
}
// Set program parameters
ParameterStereoSlic parameters;
// Verbose flag
parameters.verbose = commandParser.exist("verbose");
// Disparity factor
parameters.disparityFactor = commandParser.get<double>("factor");
// The number of superpixels
parameters.superpixelTotal = commandParser.get<int>("superpixel");
// Input files
parameters.firstLeftImageFilename = commandParser.rest()[0];
parameters.firstLeftDisparityImageFilename = commandParser.rest()[1];
parameters.cameraMotionFilename = commandParser.rest()[2];
// Output files
std::string outputSegmentImageFilename = commandParser.get<std::string>("output");
if (outputSegmentImageFilename == "") {
outputSegmentImageFilename = parameters.firstLeftImageFilename;
size_t dotPosition = outputSegmentImageFilename.rfind('.');
if (dotPosition != std::string::npos) outputSegmentImageFilename.erase(dotPosition);
outputSegmentImageFilename += "_seg.png";
}
parameters.outputSegmentImageFilename = outputSegmentImageFilename;
std::string outputBoundaryImageFilename = outputSegmentImageFilename;
size_t dotPosition = outputBoundaryImageFilename.rfind('.');
if (dotPosition != std::string::npos) outputBoundaryImageFilename.erase(dotPosition);
std::string outputDisparityImageFilename = outputBoundaryImageFilename;
std::string outputFlowImageFilename = outputBoundaryImageFilename;
std::string outputBoundaryLabelImageFilename = outputBoundaryImageFilename;
std::string outputBoundaryLabelFilename = outputBoundaryImageFilename;
//by harry
std::string outputDisparityPlaneFilename = outputBoundaryImageFilename;
outputBoundaryImageFilename += "_boundary.png";
outputDisparityImageFilename += "_disparity.png";
outputFlowImageFilename += "_flow.png";
outputBoundaryLabelImageFilename += "_label.png";
outputBoundaryLabelFilename += "_label.txt";
outputDisparityPlaneFilename += "_planes.txt";
parameters.outputBoundaryImageFilename = outputBoundaryImageFilename;
parameters.outputDisparityImageFilename = outputDisparityImageFilename;
parameters.outputFlowImageFilename = outputFlowImageFilename;
parameters.outputBoundaryLabelImageFilename = outputBoundaryLabelImageFilename;
parameters.outputBoundaryLabelFilename = outputBoundaryLabelFilename;
parameters.outputDisparityPlaneFilename = outputDisparityPlaneFilename;
return parameters;
}
run matlab function using command line
First, you need a matlab_batcher.sh file:
___________
Then for any matlab function you wanna run, using the following command (suppose the name of the function is smallrefine).
Pay attention to how we pass multiple string arguments to the matlab function.
matlab_exec=matlab
X="${1}(${2})"
echo ${X} > matlab_command_${2}.m
cat matlab_command_${2}.m
${matlab_exec} -nojvm -nodisplay -nosplash < matlab_command_${2}.m
rm matlab_command_${2}.m
___________
Then for any matlab function you wanna run, using the following command (suppose the name of the function is smallrefine).
./matlab_batcher.sh smallrefine \'$lasercamclean_p_clean\',\'$raytraceclean_p_clean\',\'$planes_trans_mat\',\'$plane_refine_mat\'
Pay attention to how we pass multiple string arguments to the matlab function.
Subscribe to:
Posts (Atom)