diff --git a/Makefile b/Makefile index b5505b9..0d1ad48 100644 --- a/Makefile +++ b/Makefile @@ -9,14 +9,14 @@ OBJECTS := $(OBJECTS) gui.oo main.oo \ videodev.oo videodev-v4l2.oo videodev-dumpfile.oo \ convert.oo filter.oo detect.oo json.oo configuration.oo ser.oo DISTNAME=simpleskycam-$(VERSION) - +DEPENDFILE=.depend ifeq ($(TARGET),) noconfig: configlinux help endif -all: Makefile.rules $(TARGET) +all: dep Makefile.rules $(TARGET) help: echo "set up configuration" @@ -54,6 +54,8 @@ $(TARGET): $(OBJECTS) .SUFFIXES: .SUFFIXES: .c .cc .C .cpp .oo +-include $(DEPENDFILE) + .cc.oo : $(INCLUDES) $(CPP) -o $@ -c $(CPPFLAGS) $< @@ -83,8 +85,6 @@ dist: clean dep: $(CXX) -MM `ls *.cc` $(CXXFLAGS) > $(DEPENDFILE) --include $(DEPENDFILE) - .PHONY: all .PHONY: count .PHONY: clean diff --git a/convert.cc b/convert.cc index 18fc44a..b29d102 100644 --- a/convert.cc +++ b/convert.cc @@ -19,6 +19,7 @@ uint32_t convert_pixelformats [] = { V4L2_PIX_FMT_RGB24, V4L2_PIX_FMT_BGR24, V4L2_PIX_FMT_UYVY, + V4L2_PIX_FMT_SGRBG16, 0 }; @@ -344,6 +345,59 @@ int Convert (ConvertData *cdata, VideoFrame *dest, unsigned char *ptrsrc, int sr } break; + case (V4L2_PIX_FMT_SGRBG16): + // GG RR + // BB GG + uint16_t t; + + for (ys = 0, yd = 0; ys < (signed int)srch; ys++) { + for (xs = 0, xd = 0; xs < (signed int)srcw; xs++) { + /* read the pixel */ + t = (*((uint16_t*)ptrsrc)) & 0x00FF; + ptrsrc += 2; + + if (xs & 1) { + if (ys & 1) { + b = 0; + g = t; + r = 0; + } + else { + b = t; + g = 0; + r = 0; + } + } + else { + if (ys & 1) { + b = 0; + g = t; + r = 0; + } + else { + b = 0; + g = 0; + r = t; + } + } + + /* only paint the image if the source is within the destination */ + if (xd < dest->w) { + /* set the pixel */ + *(ptrdst++) = b; + *(ptrdst++) = g; + *(ptrdst++) = r; + xd++; + } + } + + /* if the source image is too small ignore the other places.. */ + if (xd < dest->w) + ptrdst += 3 * (dest->w - xd); + yd++; + } + break; + case (V4L2_PIX_FMT_UYVY): for (ys = 0, yd = 0; ys < (signed int)srch; ys++) { for (xs = 0, xd = 0; xs < (signed int)srcw; xs++) { diff --git a/videodev-svbcam.cc b/videodev-svbcam.cc index 444ef30..24d3086 100644 --- a/videodev-svbcam.cc +++ b/videodev-svbcam.cc @@ -203,12 +203,18 @@ int VideoDev_SVBCam::Open() { inframe_pixfmt = convert_to_pixelformat(conf_format); switch (inframe_pixfmt) { + case (V4L2_PIX_FMT_SGRBG16): + if ((err = SVBSetOutputImageType(camid, SVB_IMG_RAW16)) != SVB_SUCCESS) { + print_error(err); + return VDEV_STATUS_ERROR; + } + break; case (V4L2_PIX_FMT_RGB32): - if ((err = SVBSetOutputImageType(camid, SVB_IMG_RGB32)) != SVB_SUCCESS) { - print_error(err); - return VDEV_STATUS_ERROR; - } - break; + if ((err = SVBSetOutputImageType(camid, SVB_IMG_RGB32)) != SVB_SUCCESS) { + print_error(err); + return VDEV_STATUS_ERROR; + } + break; case (V4L2_PIX_FMT_RGB24): if ((err = SVBSetOutputImageType(camid, SVB_IMG_RGB24)) != SVB_SUCCESS) { print_error(err); @@ -362,7 +368,8 @@ int VideoDev_SVBCam::GetDeviceFormats(string device, std::list *formats) Close(); return VDEV_STATUS_ERROR; } - printf ("%s:%d %s height: %ld width: %ld\n", __FILE__, __LINE__, __FUNCTION__, camprop.MaxHeight, camprop.MaxWidth); + printf ("%s:%d %s height: %ld width: %ld maxdepth:%d BayerPattern:%d\n", __FILE__, __LINE__, __FUNCTION__, camprop.MaxHeight, + camprop.MaxWidth, camprop.MaxBitDepth, camprop.BayerPattern); for(int i=0; i < 8 && camprop.SupportedVideoFormat[i] != SVB_IMG_END; i++) { printf ("%s:%d %s VideoFormat Index:%d ", __FILE__, __LINE__, __FUNCTION__, i); @@ -381,6 +388,7 @@ int VideoDev_SVBCam::GetDeviceFormats(string device, std::list *formats) break; case SVB_IMG_RAW16: printf("\t\tSVB_IMG_RAW16\n"); + formats->push_back(convert_from_pixelformat(V4L2_PIX_FMT_SGRBG16)); break; case SVB_IMG_Y8: printf("\t\tSVB_IMG_Y8\n");