diff options
author | deva <deva> | 2005-05-01 11:25:56 +0000 |
---|---|---|
committer | deva <deva> | 2005-05-01 11:25:56 +0000 |
commit | 90712e97bdc219492235f3ae04f3e707ae10e161 (patch) | |
tree | 4278104db2e8cc7cddb5845643a52d7e616c842e /src | |
parent | 5d169f85f64166b68fac4bc6949690d561fcb543 (diff) |
Added code to read screenshot from frame queue, decode it to rgb and put it into a qimage.
Diffstat (limited to 'src')
-rw-r--r-- | src/camera.cc | 7 | ||||
-rw-r--r-- | src/camera.h | 5 | ||||
-rw-r--r-- | src/encoder.cc | 59 | ||||
-rw-r--r-- | src/encoder.h | 7 | ||||
-rw-r--r-- | src/mainwindow.cc | 8 |
5 files changed, 79 insertions, 7 deletions
diff --git a/src/camera.cc b/src/camera.cc index b7dd8f4..6300946 100644 --- a/src/camera.cc +++ b/src/camera.cc @@ -27,6 +27,9 @@ */ /* * $Log$ + * Revision 1.9 2005/05/01 11:25:56 deva + * Added code to read screenshot from frame queue, decode it to rgb and put it into a qimage. + * * Revision 1.8 2005/05/01 09:56:26 deva * Added Id and Log tags to all files * @@ -174,9 +177,9 @@ void Camera::unfreeze() else errorstatus->pushError("Camera not initialized."); } -void Camera::snapshot() +void Camera::snapshot(unsigned char *rgb) { - if(initialized) encoder->shoot(); + if(initialized) encoder->shoot(rgb); else errorstatus->pushError("Camera not initialized."); } diff --git a/src/camera.h b/src/camera.h index 2e0126f..eafaf27 100644 --- a/src/camera.h +++ b/src/camera.h @@ -27,6 +27,9 @@ */ /* * $Log$ + * Revision 1.9 2005/05/01 11:25:56 deva + * Added code to read screenshot from frame queue, decode it to rgb and put it into a qimage. + * * Revision 1.8 2005/05/01 09:56:26 deva * Added Id and Log tags to all files * @@ -77,7 +80,7 @@ public: void stop(n_savestate save); void freeze(); void unfreeze(); - void snapshot(); + void snapshot(unsigned char *rgb); // Status methods Error *errorObject(); diff --git a/src/encoder.cc b/src/encoder.cc index 9498cb9..21e418d 100644 --- a/src/encoder.cc +++ b/src/encoder.cc @@ -25,6 +25,9 @@ */ /* * $Log$ + * Revision 1.18 2005/05/01 11:25:56 deva + * Added code to read screenshot from frame queue, decode it to rgb and put it into a qimage. + * * Revision 1.17 2005/05/01 09:56:26 deva * Added Id and Log tags to all files * @@ -36,6 +39,10 @@ #include <time.h> +// Use libdv +#include <libdv/dv.h> +#include <libdv/dv_types.h> + Encoder::Encoder(Error* err, const char *gip, const int gport, @@ -126,7 +133,12 @@ void Encoder::freeze() } -void Encoder::shoot() +/* + * shoot + * Set the shoot bit in the network header on the current frame. + * return the decodet (rgba) version af that frame, for thumbnail show. + */ +void Encoder::shoot(unsigned char *rgb) { if(!s) { s = new Socket(port, errobj); @@ -134,6 +146,7 @@ void Encoder::shoot() n = new Network(s, errobj); } if(!errobj->hasError()) shoot_request = 1 - shoot_request; + getScreenshot(rgb); } @@ -181,4 +194,48 @@ void Encoder::stop(n_savestate save) { } } + +void Encoder::getScreenshot(unsigned char *rgb) +{ + Frame *frame; + + unsigned char *pixels[3]; + int pitches[3]; + + pixels[ 0 ] = rgb; + pixels[ 1 ] = NULL; + pixels[ 2 ] = NULL; + + pitches[ 0 ] = 720 * 3; + pitches[ 1 ] = 0; + pitches[ 2 ] = 0; + + dv_decoder_t *decoder = dv_decoder_new(FALSE/*this value is unused*/, FALSE, FALSE); + decoder->quality = DV_QUALITY_BEST; + + frame = queue->peek(); + if(!frame) { + memset(rgb, 0, sizeof(rgb)); + return; + } + + dv_parse_header(decoder, frame->data); + + /* + decoder->system = e_dv_system_625_50; // PAL lines, PAL framerate + decoder->sampling = e_dv_sample_422; // 4 bytes y, 2 bytes u, 2 bytes v + decoder->std = e_dv_std_iec_61834; + decoder->num_dif_seqs = 12; + */ + + // libdv img decode to rgb + dv_decode_full_frame(decoder, + frame->data, + e_dv_color_rgb, + pixels, + pitches); + + dv_decoder_free(decoder); +} + #endif /*USE_GUI*/ diff --git a/src/encoder.h b/src/encoder.h index 32c5799..31aec20 100644 --- a/src/encoder.h +++ b/src/encoder.h @@ -24,6 +24,9 @@ */ /* * $Log$ + * Revision 1.8 2005/05/01 11:25:56 deva + * Added code to read screenshot from frame queue, decode it to rgb and put it into a qimage. + * * Revision 1.7 2005/05/01 09:56:26 deva * Added Id and Log tags to all files * @@ -73,7 +76,7 @@ public: void stop(n_savestate save); void freeze(); - void shoot(); + void shoot(unsigned char *rgb); void run(); @@ -84,6 +87,8 @@ public: volatile int *running; private: + void getScreenshot(unsigned char *rgb); + Error *errobj; int port; diff --git a/src/mainwindow.cc b/src/mainwindow.cc index 0346ed3..fccee98 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -27,9 +27,11 @@ */ /* * $Log$ + * Revision 1.17 2005/05/01 11:25:56 deva + * Added code to read screenshot from frame queue, decode it to rgb and put it into a qimage. + * * Revision 1.16 2005/05/01 09:56:26 deva * Added Id and Log tags to all files - * */ #include <config.h> #ifdef USE_GUI @@ -330,9 +332,11 @@ void MainWindow::rec_clicked() void MainWindow::shoot_clicked() { + unsigned char pixels[720*576*3]; QImage image; - camera->snapshot(); + camera->snapshot(pixels); + image.loadFromData(pixels, sizeof(pixels)); checkErrors(); image = img_live->getScreenshot(); |