Monday, June 28, 2010

Weekly Report 6

Status and Accomplishment
  • Worked on the performance benchmarking of sobel algorithm. To my surprise, the performance was found to be lower than the non-dsp OpenCV sobel algorithm. The design architecture of calling codec-engine was then changed. Earlier, the codec-engine was opened and then closed after processing the algorithm each time it was called. Now, the codec-engine remains open through the execution and then closed at the end when all the processing is done. The performance inproved and is close to non-dsp OpenCV implementation. To process and then display the video "tree.avi", that comes along with OpenCV examples, frame by frame with 50 ms wait time in between, it takes around 6 seconds compared to 5 seconds with non-dsp. I am still looking into factors to boost up the performance.
  • Extended the sobel algorithm. It is now capable of working with 5x5 and 7x7 kernel.
  • I am currently working on implementing cvIntegral and extending DFT. Tested the algorithm for calculating integral image. Some more work is needed so that it could be applied to images.
  • Looked into integration of my library with existing OpenCV library. Did some modification to existing library to conditionally call my-library after some error checking and environment-variable checkup. Had some issues with CMAKE which I have mentioned on blockers.
Plans
  • Look further into performance hurdles and try to overcome it.
  • Expand Integral algorithm and DFT algorithm.
  • Look into their performance and compare it with non-dsp OpenCV algorithm.
Blockers
  • When trying to building OpenCV library after integrating my library with existing algorithm, the linker was not able to find my library. After wasting almost a day in that, I gave it up moved on to other task. I will look into more details of CMAKE build procedure and needed changes to be done, when I am done with other algorithms. Meanwhile, I am planning to look into it only during free time.

Sunday, June 20, 2010

Weekly Report 5

Status and Accomplishment
  • Separated ARM side library and application.Tested with different images. Modified Makefile to generate an ARM side library and app executable seperately. The source can be found at http://code.google.com/p/opencv-dsp-acceleration/source/browse/.
  • Wrote building procedure which can be found at http://code.google.com/p/opencv-dsp-acceleration/wiki/Instruction_For_Building_Examples.
  • Modified the library so that it could be applied to the images captured or loaded using OpenCV API. Tested the library with image frames from webcam. Sobel algorithm works well for images of type CV_8UC1 and CV_8SC1. Its output is in the same format as the input type, however the depth change to 16 bit on original OpenCV library. I need to convert the image depth for seemless integration with OpenCV.
Plans
  • Benchmark the performance of my library. Compare its performance with that of non-dsp OpenCV library.
  • Integrate my library with OpenCV library.
  • As my earlier DFT was 1-D, need to work on it so that it could be applied to images.
Blockers
  • So far there is no blocker, but I may have some problem while integrating my library with OpenCV library. Still I don't have clear picture how it is to be implemented.

Sunday, June 13, 2010

Weekly Report 4

Status and Accomplishment
  • Successfully captured frames from Logitech webcam pro 9000 using opencv library functions.
  • Tested the code for 1-D DFT using DSPLib. Also worte code for IUNIVERSAL using Sobel_3x3,5x5 and 7x7 using IMGLib. Tested functioning of sobel_3x3 and found to work well. Wrote application for the arm side to pass an image pointer after saving it in a continious memory block and save the processed image later.
  • Executed QualiTI test for the IUNIVERSAL library package for the written code. Made some changes to comply with XDAIS standard.
Plans
  • Seperate the app and arm-side library for integration with opencv with proper namespace.
  • Look into opencv data-structure and do necessary data mangling so that I could process it using functions from DSPLib and IMGLib.
  • Further explore the webcam and process the image received from the webcam using IUNIVERSAL based engine.
Blockers
  • I have a working copy of opencv in my beagleboard, which I got from opkg installer. But I want to build one using openembedded. When I tried to "bitbake opencv" I got some error almost at the end. I am not able to solve it. The error log can be found at http://pastebin.com/vRjwx9U4 .
  • Capturing continious frames from my webcam is giving me some error message regarding invalid hauffman code. Also there is some flickering in the image periodically which is believe is due to this error. I am not sure how to solve it. Also there are few other errors as I have mentioned at http://pramodpoudel.blogspot.com/2010/06/capturing-frames-from-webcams-using.html.

Tuesday, June 8, 2010

Capturing Frames from webcams using OpenCV


After many unsuccessful try, today I finally captured some frames from my usb webcam. The webcam I am using is Logitech Webcam Pro 9000. New linux kernel, like 2.6.32 supports UVC compliant webcams. The webcam is detected as soon as you plug in the usb to the self powered USB hub. I could also see that my webcam is detected by typing

root@beagleboard:~# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 0409:005a NEC Corp. HighSpeed Hub
Bus 002 Device 003: ID 413c:1002 Dell Computer Corp. Keyboard Hub
Bus 002 Device 004: ID 0461:4d15 Primax Electronics, Ltd Dell Optical Mouse
Bus 002 Device 005: ID 046d:0809 Logitech, Inc.
Bus 002 Device 006: ID 0b95:772a ASIX Electronics Corp.
Bus 002 Device 007: ID 413c:2002 Dell Computer Corp. SK-8125 Keyboard

and for further confirmation that the UVC module is loaded I typed the following

root@beagleboard:/media/work/opencv# lsmod
Module Size Used by
g_ether 24916 0
nfsd 241018 8
nfs_acl 2173 1 nfsd
exportfs 3092 1 nfsd
ipv6 249183 10
rfcomm 33488 0
hidp 11193 0
l2cap 30104 4 rfcomm,hidp
bluetooth 49221 3 rfcomm,hidp,l2cap
rfkill 15030 1 bluetooth
rtc_twl 4451 0
rtc_core 12599 1 rtc_twl
uvcvideo 55469 0
mailbox_mach 4183 0
mailbox 3609 1 mailbox_mach

I had to struggle a little to successfully capture frames from my webcam. I searched for many
resources and finally came across http://groups.google.com/group/beagleboard/browse_thread/thread/2b2d4a50c5c77f8a/931f1e5160f9bbee?lnk=gst&q=opencv+on+bb#931f1e5160f9bbee . In this thread, a group member has pointed to setup procedure given by Don Lewis. Many thanks to the group member and Don Lewis. It was a relief after so many unsuccessful
try. I tried to follow exactly what it said. While compiling the program I got following warnings
but there were no errors.

root@beagleboard:/media/work/opencv# gcc -I/usr/include/opencv -g Capture.c -o
test -lml -lcvaux -lhighgui -lcv -lcxcore
In file included from /usr/include/opencv/cxcore.h:70,
from /usr/include/opencv/cv.h:58,
from Capture.c:5:
/usr/include/opencv/cxtypes.h: In function 'cvRound':
/usr/include/opencv/cxtypes.h:228: warning: incompatible implicit declaration of
built-in function 'lrint' root@beagleboard:/media/work/opencv#

However, execution failed giving following errors and messages on the console.

root@beagleboard:/media/work/opencv# ./test
libv4lconvert: warning more framesizes then I can handle!
libv4lconvert: warning more framesizes then I can handle!
[27996.920166] keyboard.c: can't emulate rawmode for keycode 212
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
libv4l2: error allocating conversion buffer
mmap: Cannot allocate memory
[27997.052886] uvcvideo: Failed to query (1) UVC control 4 (unit 1) : -32 (exp. 4).
HIGHGUI ERROR: V4L2: Failed to set control "10094850": Input/output error (value 305)
HIGHGUI WARNING: Setting property 10094850 through v4l2 failed. Trying with v4l1 .
HIGHGUI ERROR: V4L: property #10094850 is not supported
munmap: Invalid argument munmap: Invalid argument
munmap: Invalid argument munmap: Invalid argument
Unable to stop the stream.: Bad file descriptor
munmap: Invalid argument
munmap: Invalid argument
munmap: Invalid argument
munmap: Invalid argument
libv4lconvert: warning more framesizes then I can handle!
libv4lconvert: warning more framesizes then I can handle!
[27997.192169] keyboard.c: can't emulate rawmode for keycode 212
libv4l1: error allocating v4l1 buffer: Cannot allocate memory
HIGHGUI ERROR: V4L: Mapping Memmory from video source error: Invalid argument
HIGHGUI ERROR: V4L: Initial Capture Error: Unable to load initial memory buffers
. failed to get a video frame
OpenCV Error: Null pointer (NULL array pointer is passed) in cvGetMat, file /OE/
angstrom-dev/work/armv7a-angstrom-linux-gnueabi/opencv-2.1.0+svnr3058-r0/opencv/
src/cxcore/cxarray.cpp, line 2376 terminate called after throwing an instance of 'cv::Exception'
what(): /OE/angstrom-dev/work/armv7a-angstrom-linux-gnueabi/opencv-2.1.0+svnr
3058-r0/opencv/src/cxcore/cxarray.cpp:2376: error: (-27) NULL array pointer is p
assed in function cvGetMat
Aborted
root@beagleboard:/media/work/opencv#

Initially I could not figure out what caused to abort. I gave a try to some other example mentioned at http://blog.damiles.com/?p=61. Still the problem was same.
I then the changed the "mem" argument for uboot. Initially I had set "mem=80M". Then changed it for "mem=128M" in my uboot. Booted my Beagleboard and then run the test. This time, I could successfully capture frames although I could still see some messages on my console,

root@beagleboard:/media/work/opencv# ./test
libv4lconvert: warning more framesizes then I can handle!
libv4lconvert: warning more framesizes then I can handle!
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
[ 138.964233] uvcvideo: Failed to query (1) UVC control 4 (unit 1) : -32 (exp.
4).
HIGHGUI ERROR: V4L2: Failed to set control "10094850": Input/output error (value
305)
HIGHGUI WARNING: Setting property 10094850 through v4l2 failed. Trying with v4l1
.
HIGHGUI ERROR: V4L: property #10094850 is not supported
root@beagleboard:/media/work/opencv#

I am still not sure how to fix these warnings. I searched for this issue and find out many topics regarding it but still has not come across the solution. Ffor now I am able to capture some frames using my webcam and further need to work on adding this to my application. One of the images I captured using my webcam is the one at the top.

Monday, June 7, 2010

Weekly Report 3


Status and Accomplishment

  1. Starting of the week was devoted to resolve the issue with JTAG debugging.
  2. Then, I looked into detail of IUNIVERSAL examples.
  3. Wrote code for 1-D DFT using IUNIVERSAL taking reference as FIR example and BitBlit project. Had some issues with linking with the library files for DSPLib. It was resolved by the end of the week. I could see some output but that does not confirms to what I am supposed to get. Tried to debug it but had few issues while debugging. I have mentioned the issues below. I need to look further into it.
  4. By the end of the week, I bought a Logitech webcam, and I am trying to figure out how to capture a frame. Tried couple of times to capture frames, taking references from resources on the internet, but no success.
Plans
  1. Look further into the code I have written and expand it to accomodate other functions from IMGLib.
  2. Learn debugging on multi-core.
  3. Interface webcam and captrue frames.
Blockers
  1. Although I did not get much time to look into debugging, I had some issues about debugging on multicore. I tried to debug the code that I had compiled in Linux using CCS. Loaded the code. But I could only see assembly code, which was very tough for me to manage and keep track. Also, I could not figure out how to debug as process in DSP side depends upon the signal from ARM side.

Wednesday, June 2, 2010

Debugging with CCS4 using XDS510USB+ for Beagleboard.

It had been a while that I had not posted anything. For more that a week since the official date for coding, I was stuck on JTAG debugging and later with RTSC wizard. Since, the problem is solved now I think it is worth mentioning here and can be useful for someone who would like to use CCS4 for debugging the stuff going around in beagleboard using XDS510USB+. I will try to eleborate the problem I faced and how I overcame it.

Problem: After I lunched the debugger, I was able to connect to the CortexA8 of the beagleboard but not to the DSP. And later not able to load my program even I could connect to the DSP.

Solution:

Updated my CCS4 to Version 4.1.2.00027

Used gel files: sdomap35xx_c64plus.gel for DSP

Beagle_Omap35xx_CortexA8.gel

Whenever I tried to connect to the DSP of beagleboard, it gave error message containing "...no cpu clock...". I knew it that the DSP is in the reset mode and it should be released from the reset mode. But the gel script to reset did not work for me. I could see 'Scripts->OMAP35xx Functions->C64xPlusRelease_FromReset'. When ever I executed this, there was no result and any message on the console. Then I modified one of the dsplink example as in http://processors.wiki.ti.com/index.php/Debugging_the_DSP_side_of_a_DSPLink_application_on_OMAP-L138_using_CCS, powered on the beagleboard, loaded the necessary modules to run the DSPLink example. Started CCS4, started the debug session. In the beagle boarad, i executed the sample example which release the DSP from reset and and keeps it in a infinite loop. On the code composer studio, I the clicked 'Connect Target'. The CCS4 was then connected to the DSP. But still I was not able to load my program. Trying to load my program gave me diffirent error message like ..DSP is in wait-in-reset mode...any some time other.

The solution to this was simply to wait. I was so desperate to test my DSP that I never bothered to wait. If I try to play with the DSP and load my program before the example code finish its execution (which took almost 2 minutes as the DSP was in infinite loop and gpp side exit with failed status), then I could not do anything after that. Any attempt to run execution and tricks was unsuccessful as I always used to try to load my program and did not wait that long. After the example is finished executing the wait was over. I could then load any program and step through.

Also, it is worth mentioning and I don't know why, after I terminate the debug session, my beagleboard is dead and I have to hard reset it to give back life.