Subcamera Option for Camera Capture (#2521)

* camera capture modification

* add subcamera option

* update less file
This commit is contained in:
shun-iwasawa 2019-04-01 16:24:11 +09:00 committed by masafumi-inoue
parent cd6e9e4b6f
commit f28b21fa88
9 changed files with 1003 additions and 205 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="18"
height="18"
viewBox="0 0 18 18"
id="svg4147"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="subcamera.svg">
<defs
id="defs4149" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="38.541667"
inkscape:cx="12"
inkscape:cy="6.8108108"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
showguides="true"
units="px"
inkscape:window-width="1920"
inkscape:window-height="1139"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid4695" />
</sodipodi:namedview>
<metadata
id="metadata4152">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="レイヤー 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1034.3622)">
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#181818;fill-opacity:1;fill-rule:nonzero;stroke:#181818;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect4810-7-6"
width="4"
height="4"
x="13"
y="1047.3622" />
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#181818;fill-opacity:1;fill-rule:nonzero;stroke:#181818;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect4810-9"
width="4"
height="4"
x="1"
y="1047.3622" />
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#181818;fill-opacity:1;fill-rule:nonzero;stroke:#181818;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect4810-7"
width="4"
height="4"
x="13"
y="1035.3622" />
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#181818;fill-opacity:1;fill-rule:nonzero;stroke:#181818;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect4810"
width="4"
height="4"
x="1"
y="1035.3622" />
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:0;fill-rule:nonzero;stroke:#181818;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect4703"
width="12"
height="12"
x="3"
y="1037.3622" />
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:0;fill-rule:nonzero;stroke:#ebebeb;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect4703-3"
width="12"
height="12"
x="3"
y="1037.3622" />
<rect
style="opacity:1;fill:#181818;fill-opacity:1;stroke:#ebebeb;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4701-1-6"
width="3"
height="3"
x="13.5"
y="1035.8622" />
<rect
style="opacity:1;fill:#181818;fill-opacity:1;stroke:#ebebeb;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4701-3"
width="3"
height="3"
x="1.5"
y="1035.8622" />
<rect
style="opacity:1;fill:#181818;fill-opacity:1;stroke:#ebebeb;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4701-1-6-5"
width="3"
height="3"
x="13.5"
y="1047.8622" />
<rect
style="opacity:1;fill:#181818;fill-opacity:1;stroke:#ebebeb;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4701-3-9"
width="3"
height="3"
x="1.5"
y="1047.8622" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.5 KiB

View file

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="18"
height="18"
viewBox="0 0 18 18"
id="svg4147"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="subcamera.svg">
<defs
id="defs4149" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="38.541667"
inkscape:cx="12"
inkscape:cy="6.8108108"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
showguides="true"
units="px"
inkscape:window-width="1920"
inkscape:window-height="1139"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid4695" />
</sodipodi:namedview>
<metadata
id="metadata4152">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="レイヤー 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1034.3622)">
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#181818;fill-opacity:1;fill-rule:nonzero;stroke:#181818;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect4810-7-6"
width="4"
height="4"
x="13"
y="1047.3622" />
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#181818;fill-opacity:1;fill-rule:nonzero;stroke:#181818;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect4810-9"
width="4"
height="4"
x="1"
y="1047.3622" />
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#181818;fill-opacity:1;fill-rule:nonzero;stroke:#181818;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect4810-7"
width="4"
height="4"
x="13"
y="1035.3622" />
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#181818;fill-opacity:1;fill-rule:nonzero;stroke:#181818;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect4810"
width="4"
height="4"
x="1"
y="1035.3622" />
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:0;fill-rule:nonzero;stroke:#181818;stroke-width:4;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect4703"
width="12"
height="12"
x="3"
y="1037.3622" />
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#000000;fill-opacity:0;fill-rule:nonzero;stroke:#ebebeb;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect4703-3"
width="12"
height="12"
x="3"
y="1037.3622" />
<rect
style="opacity:1;fill:#181818;fill-opacity:1;stroke:#ebebeb;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4701-1-6"
width="3"
height="3"
x="13.5"
y="1035.8622" />
<rect
style="opacity:1;fill:#181818;fill-opacity:1;stroke:#ebebeb;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4701-3"
width="3"
height="3"
x="1.5"
y="1035.8622" />
<rect
style="opacity:1;fill:#181818;fill-opacity:1;stroke:#ebebeb;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4701-1-6-5"
width="3"
height="3"
x="13.5"
y="1047.8622" />
<rect
style="opacity:1;fill:#181818;fill-opacity:1;stroke:#ebebeb;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4701-3-9"
width="3"
height="3"
x="1.5"
y="1047.8622" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.5 KiB

View file

@ -101,4 +101,12 @@ PencilTestPopup {
#SubfolderButton {
qproperty-icon: url('@{img-url}/subfolder.svg');
padding-left: 6px;
padding-right: 6px;
}
#SubcameraButton {
qproperty-icon: url('@{img-url}/subcamera.svg');
padding-left: 6px;
padding-right: 6px;
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,8 @@
#include "toonzqt/lineedit.h"
#include "toonz/namebuilder.h"
#include <QFrame>
#include <QAbstractVideoSurface>
#include <QRunnable>
// forward decl.
class QCamera;
@ -30,51 +31,149 @@ class QCameraViewfinder;
namespace DVGui {
class FileField;
class IntField;
class IntLineEdit;
}
class CameraCaptureLevelControl;
class ApplyLutTask : public QRunnable {
protected:
int m_fromY, m_toY;
QImage& m_img;
std::vector<int>& m_lut;
public:
ApplyLutTask(int from, int to, QImage& img, std::vector<int>& lut)
: m_fromY(from), m_toY(to), m_img(img), m_lut(lut) {}
private:
virtual void run() override;
};
class ApplyGrayLutTask : public ApplyLutTask {
public:
ApplyGrayLutTask(int from, int to, QImage& img, std::vector<int>& lut)
: ApplyLutTask(from, to, img, lut) {}
private:
void run() override;
};
//=============================================================================
// MyViewFinder
// MyVideoSurface
//-----------------------------------------------------------------------------
class MyViewFinder : public QFrame {
class QVideoSurfaceFormat;
class MyVideoSurface : public QAbstractVideoSurface {
Q_OBJECT
public:
MyVideoSurface(QWidget* widget, QObject* parent = 0);
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
QAbstractVideoBuffer::HandleType handleType =
QAbstractVideoBuffer::NoHandle) const;
bool isFormatSupported(const QVideoSurfaceFormat& format,
QVideoSurfaceFormat* similar) const;
bool start(const QVideoSurfaceFormat& format);
void stop();
bool present(const QVideoFrame& frame);
QRect videoRect() const { return m_targetRect; }
QRect sourceRect() const { return m_sourceRect; }
void updateVideoRect();
QTransform transform() { return m_S2V_Transform; }
private:
QWidget* m_widget;
QImage::Format m_imageFormat;
QRect m_targetRect;
QSize m_imageSize;
QRect m_sourceRect;
QVideoFrame m_currentFrame;
QTransform m_S2V_Transform; // surface to video transform
signals:
void frameCaptured(QImage& image);
};
//=============================================================================
// MyVideoWidget
//-----------------------------------------------------------------------------
class MyVideoWidget : public QWidget {
Q_OBJECT
QImage m_image;
QImage m_previousImage;
QCamera* m_camera;
QRect m_imageRect;
int m_countDownTime;
bool m_showOnionSkin;
int m_onionOpacity;
bool m_upsideDown;
QRect m_subCameraRect;
QRect m_preSubCameraRect;
QPoint m_dragStartPos;
enum SUBHANDLE {
HandleNone,
HandleFrame,
HandleTopLeft,
HandleTopRight,
HandleBottomLeft,
HandleBottomRight,
HandleLeft,
HandleTop,
HandleRight,
HandleBottom
} m_activeSubHandle = HandleNone;
void drawSubCamera(QPainter&);
public:
MyViewFinder(QWidget* parent = 0);
MyVideoWidget(QWidget* parent = 0);
~MyVideoWidget();
void setImage(const QImage& image) {
m_image = image;
update();
}
void setCamera(QCamera* camera) { m_camera = camera; }
QAbstractVideoSurface* videoSurface() const { return m_surface; }
QSize sizeHint() const;
void setShowOnionSkin(bool on) { m_showOnionSkin = on; }
void setOnionOpacity(int value) { m_onionOpacity = value; }
void setPreviousImage(QImage& prevImage) { m_previousImage = prevImage; }
void setPreviousImage(QImage prevImage) { m_previousImage = prevImage; }
void showCountDownTime(int time) {
m_countDownTime = time;
repaint();
}
void updateSize();
void setSubCameraSize(QSize size);
QRect subCameraRect() { return m_subCameraRect; }
protected:
void paintEvent(QPaintEvent* event);
void resizeEvent(QResizeEvent* event);
void paintEvent(QPaintEvent* event) override;
void resizeEvent(QResizeEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
private:
MyVideoSurface* m_surface;
protected slots:
void onUpsideDownChecked(bool on) { m_upsideDown = on; }
signals:
void startCamera();
void stopCamera();
void subCameraResized(bool isDragging);
};
//=============================================================================
@ -182,8 +281,7 @@ class PencilTestPopup : public DVGui::Dialog {
QCamera* m_currentCamera;
QString m_deviceName;
MyViewFinder* m_cameraViewfinder;
QCameraImageCapture* m_cameraImageCapture;
MyVideoWidget* m_videoWidget;
QComboBox *m_cameraListCombo, *m_resolutionCombo, *m_fileTypeCombo,
*m_colorTypeCombo;
@ -210,17 +308,19 @@ class PencilTestPopup : public DVGui::Dialog {
QToolButton* m_previousLevelButton;
QPushButton* m_subcameraButton;
DVGui::IntLineEdit *m_subWidthFld, *m_subHeightFld;
QSize m_allowedCameraSize;
#ifdef MACOSX
QCameraViewfinder* m_dummyViewFinder;
#endif
int m_timerId;
QString m_cacheImagePath;
bool m_captureWhiteBGCue;
bool m_captureCue;
void processImage(QImage& procImage);
bool importImage(QImage& image);
bool importImage(QImage image);
void setToNextNewLevel();
void updateLevelNameAndFrame(std::wstring levelName);
@ -230,7 +330,6 @@ public:
~PencilTestPopup();
protected:
void timerEvent(QTimerEvent* event);
void showEvent(QShowEvent* event);
void hideEvent(QHideEvent* event);
@ -245,7 +344,7 @@ protected slots:
void onNextName();
void onPreviousName();
void onColorTypeComboChanged(int index);
void onImageCaptured(int, const QImage&);
void onFrameCaptured(QImage& image);
void onCaptureWhiteBGButtonPressed();
void onOnionCBToggled(bool);
void onLoadImageButtonPressed();
@ -262,6 +361,10 @@ protected slots:
void onSaveInPathEdited();
void onSceneSwitched();
void onSubCameraToggled(bool);
void onSubCameraResized(bool isDragging);
void onSubCameraSizeEdited();
public slots:
void openSaveInFolderPopup();
};