zhangmeng
2023-02-06 35395f32869d0721fd8e1b614ac8cf179ebe4b98
consistent with c api
2个文件已修改
14 ■■■■■ 已修改文件
main.go 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
shmparser/shmparser.go 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.go
@@ -5,6 +5,7 @@
    "goshm/shmparser"
    "io/ioutil"
    "os"
    "strings"
    "time"
)
@@ -51,9 +52,10 @@
            if i < 2 {
                w, h = 720, 576
            }
            timestamp := strings.Replace(time.Now().Format("2006-01-02 15:04:05.000"), ".", ":", -1)
            d := readFile(f)
            shmparser.Image2Shm(shm, "cameraid", "cameraname", d, w, h, 1122331122)
            shmparser.Image2Shm(shm, "cameraid", "cameraname", timestamp, d, w, h, 1122331122)
            printImage(shm, fmt.Sprintf("./npic/%dx%d.%d", w, h, i))
        }
    } else {
@@ -62,8 +64,11 @@
            if i < 2 {
                w, h = 720, 576
            }
            timestamp := strings.Replace(time.Now().Format("2006-01-02 15:04:05.000"), ".", ":", -1)
            d := readFile(files[i])
            shmparser.Image2Shm(shm, "cameraid", "cameraname", d, w, h, 1122331122)
            shmparser.Image2Shm(shm, "cameraid", "cameraname", timestamp, d, w, h, 1122331122)
            printImage(shm, fmt.Sprintf("./npic/%dx%d.%d", w, h, i))
        }
    }
shmparser/shmparser.go
@@ -7,8 +7,6 @@
*/
import "C"
import (
    "strings"
    "time"
    "unsafe"
)
@@ -23,8 +21,7 @@
}
// Image2Shm fill image to shm
func Image2Shm(shm []byte, cid, cname string, data []byte, w, h int, fid int64) {
    timestamp := strings.Replace(time.Now().Format("2006-01-02 15:04:05.000"), ".", ":", -1)
func Image2Shm(shm []byte, cid, cname, timestamp string, data []byte, w, h int, fid int64) {
    dataptr := (*C.uchar)(unsafe.Pointer(&data[0]))
    cidbyte := str2byte(cid)