Skip to content

Commit

Permalink
Merge pull request #1 from aavogt/master
Browse files Browse the repository at this point in the history
add a cvCreateVideo wrapper
  • Loading branch information
acowley committed Sep 7, 2013
2 parents 0ad8f8f + 58b9c56 commit 8f6bfec
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
8 changes: 8 additions & 0 deletions src/OpenCV/Core/HOpenCV_wrap.c
Expand Up @@ -111,6 +111,14 @@ void dilate(const CvArr *src, CvArr *dest, int iterations)
cvDilate(src, dest, NULL, iterations);
}

CvVideoWriter* cvCreateVideoWriter2( const char* filename, int fourcc,
double fps, int frame_x, int frame_y,
int is_color CV_DEFAULT(1))
{
return cvCreateVideoWriter(filename, fourcc, fps, cvSize(frame_x, frame_y), is_color);
}


/**********************************************************/

void release_mem_storage(CvMemStorage *mem_store)
Expand Down
3 changes: 3 additions & 0 deletions src/OpenCV/Core/HOpenCV_wrap.h
Expand Up @@ -31,6 +31,9 @@ void cv_free(void *obj);
int seq_total(const CvSeq *seq);
/* CvRect *c_rect_cvGetSeqElem(const CvSeq *seq, int index); */

CvVideoWriter* cvCreateVideoWriter(const char* filename, int fourcc,
double fps, int frame_x, int frame_y, int is_color);

void c_cvRectangle(CvArr *img, int x, int y, int width, int height);

void c_cvLine(CvArr *img, int x1, int y1, int x2, int y2, double r, double g,
Expand Down
21 changes: 14 additions & 7 deletions src/OpenCV/Core/HighGui.hsc
Expand Up @@ -21,6 +21,8 @@ import Foreign.C.String
import Data.List (foldl')
import OpenCV.Core.CxCore

import Foreign.Marshal.Array

#include <opencv2/highgui/highgui_c.h>

------------------------------------------------
Expand Down Expand Up @@ -129,7 +131,7 @@ fourCC (a,b,c,d) = (c1 .&. 255) + shiftL (c2 .&. 255) 8 +
shiftL (c3 .&. 255) 16 + shiftL (c4 .&. 255) 24
where [c1,c2,c3,c4] = map (fromIntegral . fromEnum) [a,b,c,d]

foreign import ccall "opencv2/highgui/highgui_c.h cvCreateVideoWriter"
foreign import ccall "HOpenCV_wrap.h cvCreateVideoWriter2"
c_cvCreateVideoWriter :: CString -> CInt -> CDouble -> CInt -> CInt -> CInt ->
IO (Ptr CvVideoWriter)

Expand All @@ -138,20 +140,25 @@ foreign import ccall "HOpenCV_wrap.h &release_video_writer"

cvCreateVideoWriter :: FilePath -> FourCC -> Double -> (Int, Int) ->
IO (Ptr CvVideoWriter)
cvCreateVideoWriter fname codec fps (w, h) =
cvCreateVideoWriter fname codec fps (w,h) = do
withCString fname $ \str ->
c_cvCreateVideoWriter str (fourCC codec) (realToFrac fps)
(fromIntegral w) (fromIntegral h) 1
(fromIntegral w) (fromIntegral h) 1

-- |Create a video file writer.
createVideoWriterF :: FilePath -> FourCC -> Double -> (Int, Int) ->
IO (ForeignPtr CvVideoWriter)
createVideoWriterF fname codec fps sz = createForeignPtr cp_release_writer $
cvCreateVideoWriter fname codec fps sz
createVideoWriterF fname codec fps sz =
createForeignPtr cp_release_writer $ cvCreateVideoWriter fname codec fps sz

foreign import ccall "opencv2/highgui/highgui_c.h cvWriteFrame"
cvWriteFrame :: Ptr CvVideoWriter -> Ptr IplImage -> IO ()

{-
foreign import ccall "opencv2/core/types_c.h cvSize"
cvSize :: Int -> Int -> IO (Ptr ())
-}

-------------------------------------------------
-- Windows
foreign import ccall "HOpenCV_wrap.h new_window"
Expand Down Expand Up @@ -247,4 +254,4 @@ enumToEventFlags x = map fst . filter snd $
-- Qt fonts
-- foreign import ccall "opencv2/highgui/highgui_c.h cvFontQt"
-- cvFontQt :: CString -> CInt -> CDouble -> CDouble -> CDouble ->
-- CInt -> CInt -> CInt -> IO CvFont
-- CInt -> CInt -> CInt -> IO CvFont

0 comments on commit 8f6bfec

Please sign in to comment.