PIXNET Logo登入

Person

跳到主文

~每天早晨醒來,看見你和陽光都在,這就是我想要的未來~

部落格全站分類:心情日記

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 1月 15 週五 201610:01
  • RTMP writer

#include "rtmp.h"
class RTMPWriter : public SrsFileWriter
(繼續閱讀...)
文章標籤

Person 發表在 痞客邦 留言(0) 人氣(19)

  • 個人分類:
▲top
  • 5月 26 週一 201419:32
  • zbar and jpeg file input



#include <stdio.h>
#include <stdlib.h>
#ifdef ENABLED_PNG
#include <png.h>
#endif
#include <zbar.h>
#include <jpeglib.h>
#include <jerror.h>

zbar_image_scanner_t *scanner = NULL;

#ifdef ENABLED_PNG
/* to complete a runnable example, this abbreviated implementation of
* get_data() will use libpng to read an image file. refer to libpng
* documentation for details
*/
static void get_data (const char *name,
int *width, int *height,
void **raw)
{
FILE *file = fopen(name, "rb");
if(!file) exit(2);
png_structp png =
png_create_read_struct(PNG_LIBPNG_VER_STRING,
NULL, NULL, NULL);
if(!png) exit(3);
if(setjmp(png_jmpbuf(png))) exit(4);
png_infop info = png_create_info_struct(png);
if(!info) exit(5);
png_init_io(png, file);
png_read_info(png, info);
/* configure for 8bpp grayscale input */
int color = png_get_color_type(png, info);
int bits = png_get_bit_depth(png, info);
if(color & PNG_COLOR_TYPE_PALETTE)
png_set_palette_to_rgb(png);
if(color == PNG_COLOR_TYPE_GRAY && bits < 8)
png_set_expand_gray_1_2_4_to_8(png);
if(bits == 16)
png_set_strip_16(png);
if(color & PNG_COLOR_MASK_ALPHA)
png_set_strip_alpha(png);
if(color & PNG_COLOR_MASK_COLOR)
png_set_rgb_to_gray_fixed(png, 1, -1, -1);
/* allocate image */
*width = png_get_image_width(png, info);
*height = png_get_image_height(png, info);
*raw = malloc(*width * *height);
png_bytep rows[*height];
int i;
for(i = 0; i < *height; i++)
rows[i] = *raw + (*width * i);
png_read_image(png, rows);
}
#endif

void print_jpeg_info(struct jpeg_decompress_struct *cinfo)
{
printf("JPEG File Information: \n");
printf("Image width and height: %d pixels and %d pixels.\n", cinfo->image_width, cinfo->image_height);
printf("Color components per pixel: %d.\n", cinfo->num_components);
printf("Color space: %d.\n", cinfo->jpeg_color_space);
printf("Raw flag is: %d.\n", cinfo->raw_data_out);
}

static int get_jpeg_data (const char *filename,
int *width, int *height,
void **raw)
{
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr err; //the error handler
/* More stuff */
int ret;
FILE * infile; /* source file */
JSAMPARRAY buffer; /* Output row buffer */
unsigned char * rowptr[1]; // pointer to an array
int row_stride; /* physical row width in output buffer */
if ((infile = fopen(filename, "rb")) == NULL) {
fprintf(stderr, "can't open %s\n", filename);
return 0;
}

/* Step 1: allocate and initialize JPEG decompression object */

/* We set up the normal JPEG error routines, then override error_exit. */
cinfo.err = jpeg_std_error(&err);
/* Now we can initialize the JPEG decompression object. */

jpeg_create_decompress(&cinfo);

/* Step 2: specify data source (eg, a file) */

jpeg_stdio_src(&cinfo, infile);

/* Step 3: read file parameters with jpeg_read_header() */

(void) jpeg_read_header(&cinfo, TRUE);
/* Step 4: set parameters for decompression */
cinfo.out_color_space = JCS_GRAYSCALE;
//cinfo.num_components = 1;

print_jpeg_info(&cinfo);

/* Step 5: Start decompressor */

(void) jpeg_start_decompress(&cinfo);

*width = cinfo.image_width;
*height = cinfo.image_height;

row_stride = cinfo.output_width * cinfo.output_components;

*raw = (void *)malloc(cinfo.output_width * cinfo.output_height * 3);

long counter = 0;

//step 6, read the image line by line
unsigned bpl = cinfo.output_width * cinfo.output_components;
JSAMPROW buf = (void*)*raw;
JSAMPARRAY line = &buf;
for(; cinfo.output_scanline < cinfo.output_height; buf += bpl) {
jpeg_read_scanlines(&cinfo, line, 1);
/* FIXME pad out to dst->width */
}
/*
while (cinfo.output_scanline < cinfo.output_height) {
// Enable jpeg_read_scanlines() to fill our jdata array
rowptr[0] = (unsigned char *)(*raw) + // secret to method
3* cinfo.output_width * cinfo.output_scanline;

jpeg_read_scanlines(&cinfo, rowptr, 1);

}*/

/* Step 7: Finish decompression */

(void) jpeg_finish_decompress(&cinfo);
/* Step 8: Release JPEG decompression object */

/* This is an important step since it will release a good deal of memory. */
jpeg_destroy_decompress(&cinfo);

fclose(infile);
/* And we're done! */
return 1;
}

int main (int argc, char **argv)
{
if(argc < 2) return(1);

/* create a reader */
scanner = zbar_image_scanner_create();

/* configure the reader */
zbar_image_scanner_set_config(scanner, 0, ZBAR_CFG_ENABLE, 1);

/* obtain image data */
int width = 0, height = 0;
void *raw = NULL;
//get_data(argv[1], &width, &height, &raw);
printf("load %s\n", argv[1]);
get_jpeg_data(argv[1], &width, &height, &raw);
printf("load %s done\n", argv[1]);

/* wrap image data */
zbar_image_t *image = zbar_image_create();
zbar_image_set_format(image, *(int*)"Y800");
zbar_image_set_size(image, width, height);
zbar_image_set_data(image, raw, width * height, zbar_image_free_data);

printf("starting to scan\n");
/* scan the image for barcodes */
int n = zbar_scan_image(scanner, image);

/* extract results */
const zbar_symbol_t *symbol = zbar_image_first_symbol(image);
for(; symbol; symbol = zbar_symbol_next(symbol)) {
/* do something useful with results */
zbar_symbol_type_t typ = zbar_symbol_get_type(symbol);
const char *data = zbar_symbol_get_data(symbol);
printf("decoded %s symbol \"%s\"\n",
zbar_get_symbol_name(typ), data);
}

/* clean up */
zbar_image_destroy(image);
zbar_image_scanner_destroy(scanner);

return(0);
}

(繼續閱讀...)
文章標籤

Person 發表在 痞客邦 留言(0) 人氣(360)

  • 個人分類:工作備忘錄
▲top
  • 8月 26 週日 201211:14
  • 編譯GDB7.5 with arm-his

用了His最新toolchain: arm-hisiv100nptl-linux-gcc (Hisilicon_v100(gcc4.4-290+uclibc_0.9.32.1+eabi+linuxpthread)) 4.4.1
編了gdb7.5,立刻就出現下列錯誤
compile warning "configure: error: no termcap library found"
(繼續閱讀...)
文章標籤

Person 發表在 痞客邦 留言(0) 人氣(244)

  • 個人分類:
▲top
  • 4月 19 週四 201217:20
  • google map usage

GPS 座標轉 google map

<!DOCTYPE html>
<html>
<head>
<metaname="viewport"content="initial-scale=1.0, user-scalable=no"/>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
#map_canvas { height: 100% }
</style>
<scripttype="text/javascript"
    src="https://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
function initialize() {
// N25 04.1472 E121 36.7195
var latlng = new google.maps.LatLng(25+(4.1472/60), 121+(36.7195/60));
var myOptions = {
zoom: 16,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
var marker = new google.maps.Marker({
position: latlng,
map: map,
title:"Hello World!"
});
}

</script>
</head>
<bodyonload="initialize()">
<divid="map_canvas"style="width:100%;height:100%"></div>
</body>
</html>
(繼續閱讀...)
文章標籤

Person 發表在 痞客邦 留言(0) 人氣(22)

  • 個人分類:
▲top
  • 3月 31 週六 201209:28
  • vsftpd 續傳功能驗證

listen=YES
#listen_ipv6=YES
anonymous_enable=YES
anon_root=/srv/ftp
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=YES
# anon_other_write_enable --> anonymous resume, delete, rename...function
anon_other_write_enable=YES
anon_mkdir_write_enable=YES
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=vsftpd
ssl_enable=YES
allow_anon_ssl=YES
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
require_ssl_reuse=NO
rsa_cert_file=/etc/vsftpd.pem
(繼續閱讀...)
文章標籤

Person 發表在 痞客邦 留言(0) 人氣(658)

  • 個人分類:程式語言
▲top
  • 11月 02 週三 201115:51
  • FastCGI和lighttpd使用心得

White paper: FastCGI: A High-Performance Web Server Interface (http://www.fastcgi.com/drupal/node/6?q=node/15)
如果FastCGI在編譯的時候, 發生了EOF Error未定義的問題. 只要在fcgio.cpp的檔案補上#include <cstdio.h>即可解決.
 
(繼續閱讀...)
文章標籤

Person 發表在 痞客邦 留言(0) 人氣(1,809)

  • 個人分類:工作備忘錄
▲top
  • 7月 27 週三 201117:26
  • 計算執行時間

 
#if BLD_WIN_LIKE || VXWORKS
int gettimeofday(struct timeval *tv, struct timezone *tz)
{
    #if BLD_WIN_LIKE
        FILETIME        fileTime;
        MprTime         now;
        static int      tzOnce;
        if (NULL != tv) {
            /* Convert from 100-nanosec units to microsectonds */
            GetSystemTimeAsFileTime(&fileTime);
            now = ((((MprTime) fileTime.dwHighDateTime) << BITS(uint)) + ((MprTime) fileTime.dwLowDateTime));
            now /= 10;
            now -= TIME_GENESIS;
            tv->tv_sec = (long) (now / 1000000);
            tv->tv_usec = (long) (now % 1000000);
        }
        if (NULL != tz) {
            TIME_ZONE_INFORMATION   zone;
            int                     rc, bias;
            rc = GetTimeZoneInformation(&zone);
            bias = (int) zone.Bias;
            if (rc == TIME_ZONE_ID_DAYLIGHT) {
                tz->tz_dsttime = 1;
            } else {
                tz->tz_dsttime = 0;
            }
            tz->tz_minuteswest = bias;
        }
        return 0;
    #elif VXWORKS
        struct tm       tm;
        struct timespec now;
        time_t          t;
        char            *tze, *p;
        int             rc;
        if ((rc = clock_gettime(CLOCK_REALTIME, &now)) == 0) {
            tv->tv_sec  = now.tv_sec;
            tv->tv_usec = (now.tv_nsec + 500) / MS_PER_SEC;
            if ((tze = getenv("TIMEZONE")) != 0) {
                if ((p = strchr(tze, ':')) != 0) {
                    if ((p = strchr(tze, ':')) != 0) {
                        tz->tz_minuteswest = mprAtoi(++p, 10);
                    }
                }
                t = tickGet();
                tz->tz_dsttime = (localtime_r(&t, &tm) == 0) ? tm.tm_isdst : 0;
            }
        }
        return rc;
    #endif
}
#endif /* BLD_WIN_LIKE || VXWORKS */
/*
    Returns time in milliseconds since the epoch: 0:0:0 UTC Jan 1 1970.
 */
MprTime mprGetTime(MprCtx ctx)
{
#if VXWORKS
    struct timespec  tv;
    clock_gettime(CLOCK_REALTIME, &tv);
    return (MprTime) (((MprTime) tv.tv_sec) * 1000) + (tv.tv_nsec / (1000 * 1000));
#else
    struct timeval  tv;
    gettimeofday(&tv, NULL);
    return (MprTime) (((MprTime) tv.tv_sec) * 1000) + (tv.tv_usec / 1000);
#endif
}
/*
    High resolution timer
 */
#if MPR_HIGH_RES_TIMER
    #if BLD_UNIX_LIKE
        uint64 mprGetTicks() {
            uint64  now;
            __asm__ __volatile__ ("rdtsc" : "=A" (now));
            return now;
        }
    #elif BLD_WIN_LIKE
        uint64 mprGetTicks() {
            LARGE_INTEGER  now;
            QueryPerformanceCounter(&now);
            return (((uint64) now.HighPart) << 32) + now.HighPart;
        }
    #else
        uint64 mprGetTicks() {
            return (uint64) mprGetTime();
        }
    #endif
#else 
    uint64 mprGetTicks() {
        return 0;
    }
#endif
#if BLD_DEBUG
    #if MPR_HIGH_RES_TIMER
        #define MEASURE(ctx, tag1, tag2, op) \
            if (1) { \
                char tags[64]; \
                MprTime elapsed, start = mprGetTime(ctx); \
                uint64  ticks = mprGetTicks(); \
                mprSprintf(tags, sizeof(tags) - 1, "%s.%s", tag1, tag2); \
                op; \
                elapsed = mprGetTime(ctx) - start; \
                if (elapsed < 1000) { \
                    mprLog(ctx, 4, "TIME: %s elapsed %,d msec, %,d ticks", tags, elapsed, mprGetTicks() - ticks); \
                } else { \
                    mprLog(ctx, 4, "TIME: %s elapsed %,d msec", tags, elapsed); \
                } \
            } else 
    #else
        #define MEASURE(ctx, tag1, tag2, op) \
            if (1) { \
                char tags[64]; \
                MprTime start = mprGetTime(ctx); \
                mprSprintf(tags, sizeof(tags) - 1, "%s.%s", tag1, tag2); \
                op; \
                mprLog(ctx, 4, "TIME: %s elapsed %,d msec", tags, mprGetTime(ctx) - start); \
            } else 
    #endif
#else
    #define MEASURE(ctx, tag1, tag2, op) op
#endif
(繼續閱讀...)
文章標籤

Person 發表在 痞客邦 留言(0) 人氣(399)

  • 個人分類:程式語言
▲top
  • 7月 15 週五 201115:47
  • passing the file descriptor by unix domain socket

Unix domain sockets have a unique ability to pass file descriptors.
#include <sys/sockets.h>
int sendmsg(int fd, const struct msghdr *msg, unsigned int flags);
int recvmsg(int fd, struct msghdr *msg, unsigned int flags);
(繼續閱讀...)
文章標籤

Person 發表在 痞客邦 留言(2) 人氣(280)

  • 個人分類:程式語言
▲top
  • 6月 30 週四 201114:42
  • gsoap example

製作一個calc的webservice
下載gsoap toolkit, linux必須安裝byacc, flex, bsion, openssl lib.
./configure --without-yacc (需要補上without-yacc,不然會出現-ly找不到的問題)
安裝完之後,主要會有兩個執行檔 
(繼續閱讀...)
文章標籤

Person 發表在 痞客邦 留言(1) 人氣(517)

  • 個人分類:工作備忘錄
▲top
  • 5月 30 週一 201117:14
  • Centos公司伺服器安裝筆記

1.yum install samba, apache, subversion
2.samba configuration
security = server
password server = 192.168.1.2
[homes]
        comment = Home Directories
        browseable = no
        writable = yes
        valid users = yoko-tech.com\personlin
(繼續閱讀...)
文章標籤

Person 發表在 痞客邦 留言(0) 人氣(232)

  • 個人分類:工作備忘錄
▲top
12...5»

熱門文章

  • (1,797)IR Driver (kernel 2.6.18)
  • (1,161)CImg筆記
  • (1,141)livemedia 實作RTSP Server
  • (84)ACER 5820TG標準配備入手

最新文章

  • RTMP writer
  • zbar and jpeg file input
  • 編譯GDB7.5 with arm-his
  • google map usage
  • vsftpd 續傳功能驗證
  • FastCGI和lighttpd使用心得
  • 計算執行時間
  • passing the file descriptor by unix domain socket
  • gsoap example
  • Centos公司伺服器安裝筆記

文章分類

  • 生活 (2)
  • 理財 (3)
  • 記賬 (0)
  • 工作備忘錄 (15)
  • 推薦 (5)
  • 一些知識 (1)
  • TI (2)
  • 程式語言 (14)
  • 未分類文章 (1)

個人資訊

Person
暱稱:
Person
分類:
心情日記
好友:
累積中
地區:

最新留言

  • [16/02/29] paultsai666 於文章「IR Driver (kernel 2....」留言:
    Person 你好: 我目前使用你所提供的Code 下...
  • [15/04/21] fred 於文章「TI DM365/368切換...」留言:
    您好 最近在學習TI相關問題 想請教您相關問題 方便跟...
  • [13/07/16] www.alkalinediet.in 於文章「gsoap example...」留言:
    http://www.alkalinediet.in...
  • [12/07/12] zenstv 於文章「TI DM365/368切換...」留言:
    請問您是從是這方面的產業嗎 最近在開發產品 需要一些有關硬...
  • [12/04/14] Person 於文章「passing the file des...」留言:
    恩恩~有機會再msn聊~ person @ networ...
  • [12/04/11] jash.liao 於文章「passing the file des...」留言:
    我也有在寫C++ 歡迎交流一下...

文章搜尋

參觀人氣

  • 本日人氣:
  • 累積人氣: