공돌이는 파닥파닥

어디서 놓친건지는 모르겠지만...


아마도 버젼업이 되어서 그런것 같기도 하고 -_-;;


쨋든 명령어는


gcc -dynamiclib -I/System/Library/Frameworks/JavaVM.framework/Headers -o libhello.jnilib ./hello_HelloJNI.c


이래 치니까 그냥 됬다.


아이고 내 시간...

Comment +0

The latest Long Term Support version of Ubuntu(12.04 LTS) is out and a new version of OpenCV was released as well. This means that now is a great opportunity to update my OpenCV installation guide to the latest versions, Ubuntu 12.04 LTS and OpenCV 2.4.1.

We are going to setup OpenCV to use the new Qt highgui interface, which is much better than the simple highgui interface. Also, we will install OpenCV with support for OpenGL, as well as reading and writing videos, access to a webcam, Python, C and C++ interfaces, and Intel Threading Building Blocks (TBB).

OK, so the first step is to make sure that everything in the system is updated and upgraded:

1sudo apt-get update
2sudo apt-get upgrade

Now, you need to install many dependencies, such as support for reading and writing image files, drawing on the screen, some needed tools, etc… This step is very easy, you only need to write the following command in the Terminal:

1sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev

Time to get the OpenCV 2.4.1 source code:

1cd ~
3tar -xvf OpenCV-2.4.1.tar.bz2
4cd OpenCV-2.4.1

Now we have to generate the Makefile by using cmake. In here we can define which parts of OpenCV we want to compile. Since we want to use Python, TBB, OpenGL, Qt, work with videos, etc, here is where we need to set that. Just execute the following line at the terminal to create the appropriate Makefile. Note that there are two dots at the end of the line, it is an argument for the cmake program and it means the parent directory (because we are inside the build directory, and we want to refer to the OpenCV directory, which is its parent).

1mkdir build
2cd build
3cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..

Check that the above command produces no error and that in particular it reports FFMPEG as YES. If this is not the case you will not be able to read or write videos. Also, check that Python, TBB, OpenGL, V4L, OpenGL and Qt are detected.

If anything is wrong, go back, correct the errors by maybe installing extra packages and then run cmake again. You should see something similar to this:

Now, you are ready to compile and install OpenCV 2.4.1:

1make
2sudo make install

Now you have to configure OpenCV. First, open the opencv.conf file with the following code:

1sudo gedit /etc/ld.so.conf.d/opencv.conf

Add the following line at the end of the file(it may be an empty file, that is ok) and then save it:

1/usr/local/lib


Run the following code to configure the library:

1sudo ldconfig

Now you have to open another file:

1sudo gedit /etc/bash.bashrc

Add these two lines at the end of the file and save it:

1PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
2export PKG_CONFIG_PATH

Finally, close the console and open a new one, restart the computer or logout and then login again. OpenCV will not work correctly until you do this.

Now you have OpenCV 2.4.1 installed in your computer with Python, TBB, OpenGL, video, and Qt support.

Check out the cool Qt interface which provides image viewing capabilities with zoom, as well as the ability to save the current image with just one click.


http://www.samontab.com/web/2012/06/installing-opencv-2-4-1-ubuntu-12-04-lts/

Comment +0

Ubuntu 12.04.1에서.


매번 패키지 업데이트를 하다 보면


자꾸 그래픽 드라이버를 건드리는데,


재부팅을 하고 나면 번번히 해상도가 낮은 상태에서 벗어나질 못한다.


지난 번에는 이렇게 나오다가 아싸리 검은 화면이 나오고 뭐.. 그랬었는데

(그래서 결국 싹 밀고 다시 설치 했는데)


이제는 겁도 나지 않고 짜증도 나지 않는다!


Ctrl+Alt+F1(혹은 F2~F6, F8)을 눌러 콘솔을 띄움.


$ sudo service gdm stop

만약 lightdm을 쓰고 있다면

$ sudo service lightdm stop


한 후, 나의 경우 cuda tool kit의 드라이버를 설치해야 하므로


$sudo CUDA설치하는못된파일


그리고 설치를 끝낸 후


$sudo service gdm start


하면 끝...

Comment +0

결과

위 코드는 중간중간 수정해서 컴파일이 안될 수 있는데, 얘기하고자 하는 바는

tbb를 이용하여 스레드를 돌리고 boost를 이용해 conditional variable을 사용한 경우

pthread를 이용한 것과 같은 결과가 나온다는 것이다.

*심지어 프로세스가 terminate도 되지 않는다.

결과2

그래서 나온 코드.

원하는 대로 잘 돌아 간다.

마지막에 delete를 안했는데, 뭐.. 크게 상관은 없는 듯.

오히려 포인터를 이용한 new가 아니라 지역변수로 잡고 그 주소를 넘긴 경우

희안하게도 ~thread()에서 같은  공간을 delete 한다며 SIGART가 뜬다.


이 모든 것은 멀티스레드 환경에서 conditional variable과 queuing lock을 사용하기 위함...

boost에서 lock이 lock_free() 혹은 only local spinning인지 알 수가 없으므로..


Comment +0


그나저나 tbb에서 conditional variable이 아직 미흡할 줄은 몰랐다.

아니면 내가 공부를 미진하게 한거겠지 -_-;


*그런데 이렇게 하면 이상하게도 7개 정도의 스레드만 wait을 하다가 signal을 받고 다른 애들이 wait을 하기 시작한다.

*확인되지는 않았지만 문제가 있는 것이 분명하므로.. 다른 방법을 생각해 봐야 한다.

Comment +0

arch=$(uname -m)
if [ "$arch" == "i686" -o "$arch" == "i386" -o "$arch" == "i486" -o "$arch" == "i586" ]; then
flag=1
else
flag=0
fi
echo "Installing OpenCV 2.4.2"
mkdir OpenCV
cd OpenCV
echo "Removing any pre-installed ffmpeg and x264"
sudo apt-get remove ffmpeg x264 libx264-dev
echo "Installing Dependenices"
sudo apt-get install libopencv-dev
sudo apt-get install build-essential checkinstall cmake pkg-config yasm
sudo apt-get install libtiff4-dev libjpeg-dev libjasper-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev
sudo apt-get install python-dev python-numpy
sudo apt-get install libtbb-dev
sudo apt-get install libqt4-dev libgtk2.0-dev
echo "Downloading x264"
wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20120528-2245-stable.tar.bz2
tar -xvf x264-snapshot-20120528-2245-stable.tar.bz2
cd x264-snapshot-20120528-2245-stable/
echo "Installing x264"
if [ $flag -eq 1 ]; then
./configure --enable-static
else
./configure --enable-shared --enable-pic
fi
make
sudo make install
cd ..
echo "Downloading ffmpeg"
wget http://ffmpeg.org/releases/ffmpeg-0.11.1.tar.bz2
echo "Installing ffmpeg"
tar -xvf ffmpeg-0.11.1.tar.bz2
cd ffmpeg-0.11.1/
if [ $flag -eq 1 ]; then
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
else
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --enable-shared
fi
make
sudo make install
cd ..
echo "Downloading v4l"
wget http://www.linuxtv.org/downloads/v4l-utils/v4l-utils-0.8.8.tar.bz2
echo "Installing v4l"
tar -xvf v4l-utils-0.8.8.tar.bz2
cd v4l-utils-0.8.8/
make
sudo make install
cd ..
echo "Downloading OpenCV 2.4.2"
wget -O OpenCV-2.4.2.tar.bz2 http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.2/OpenCV-2.4.2.tar.bz2/download
echo "Installing OpenCV 2.4.2"
tar -xvf OpenCV-2.4.2.tar.bz2
cd OpenCV-2.4.2
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE ..
make
sudo make install
sudo echo “/usr/local/lib” >> /etc/ld.so.conf
sudo ldconfig
echo "OpenCV 2.4.2 ready to be used"

Comment +0

http://ideasnet.wordpress.com/2012/07/08/ides-desktop-backup-restore-your-whole-ubuntu-computer-using-remastersys-on-ubuntu-12-04lts-desktop-edition/

Comment +0


OpenMP 를 이용한 병행처리 CPU Throughput

OpenMP를 이용한 병행처리시 CPU Throughput. 수행시간은 26초



pthread 를 이용한 병행처리 CPU Throughput

pthread를 이용한 병행처리 CPU Throughput. 수행시간은 24초



Lock이 아니라 AtomicIncrement를 이용한 카운트에서는 OpenMP가 월등히 좋은 성능을 보였었다.

그러나 막상 Lock을 구현하고 실험을 해 보면 OpenMP에서 CPU burst가 생기지만 pthread에서는 생기지 않았다.

도대체 왜 그런걸까요?


Comment +0

사실 말이 안된다.


왜냐하면 네트워크 환경에서,


내가 요청한 작업이:

1. 끝났는데 네트워크에 문제가 있어서 안온건지

2. 작업이 끝나기 전에 원격 컴퓨터가 뻗었는지

3. 아직 작업 중인지 (정해진 시간 간격으로 신호를 보내는 방법이 있겠다만은 별로 효율적이지는 않은 것 같다.)


요즘 듣는 멀티프로세서 동기화 수업에서는 절대로 원격지의 프로세스가 어떻게 되고 있는지를 알 수 있는 방법은 없다고 한다.


그러나! 나는 고신뢰를 넘어 실시간 분산 시스템(가칭)이란게 있으면 재밌지 않을까 싶다.

(혹은 이미 있거나.)

'소프트웨어 > 연구거리' 카테고리의 다른 글

실시간 분산 시스템  (0) 2012.09.13

Comment +0

Ubuntu GNU/Linux 12.04 LTS (Precise Pangolin) released. I wanted to manually install the Sun JDK 6 and 7 on Ubuntu.

Installing Sun JDK 6 on Ubuntu 12.04:

  • Make the bin file executeable:
chmod +x jdk-6u32-linux-x64.bin
  • Extract the bin file:
./jdk-6u32-linux-x64.bin
  • Move extracted folder to this location:
sudo mv jdk1.6.0_32 /usr/lib/jvm/
  • Install new java source in system:
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_32/bin/javac 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_32/bin/java 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_32/bin/javaws 1
  • Choose default java:
sudo update-alternatives --config javac
sudo update-alternatives --config java
sudo update-alternatives --config javaws
  • java version test:
java -version
  • Verify the symlinks all point to the new java location:
ls -la /etc/alternatives/java*
  • Enable Java plugin for Mozilla Firefox (even for Chrome)
#for 64-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.6.0_32/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins
#for 32-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.6.0_32/jre/lib/i386/libnpjp2.so /usr/lib/mozilla/plugins

Installing Sun JDK 7 on Ubuntu 12.04:

  • Download the sun jdk 7 tar file from here
  • Extract the tar file:
tar -xvzf jdk-7u4-linux-x64.tar.gz
  • Move extracted folder to this location:
sudo mv jdk1.7.0_04 /usr/lib/jvm/
  • Install new java source in system:
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_04/bin/javac 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_04/bin/java 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.7.0_04/bin/javaws 1
  • Choose default java:
sudo update-alternatives --config javac
sudo update-alternatives --config java
sudo update-alternatives --config javaws
  • java version test:
java -version
  • Verify the symlinks all point to the new java location:
ls -la /etc/alternatives/java*
  • Enable Java plugin for Mozilla Firefox (even for Chrome)
#for 64-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.7.0_04/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins
#for 32-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.7.0_04/jre/lib/i386/libnpjp2.so /usr/lib/mozilla/plugins

Update: I have added Java Web Start configuration (Thanks Jack).

Update: I have added Java Plugin configuration for Mozilla Firefox even for Chrome (Thanks shetty).

Update: JAVA_HOME configuration: Some tools require JAVA_HOME variable. You can set JAVA_HOME in Ubuntu so simple: Edit the file .bashrc under your home directory and add the following lines: (if .bashrc is hidden click in Nautilus Menu View > Show Hidden Files)

export JAVA_HOME=/path/your/jdk
export PATH=$JAVA_HOME/bin:$PATH

Comment +0