PDA

View Full Version : Compiler throws C6728 upon instantiation of tVideoCaptureDeviceItem



Michen
December 3, 2015, 15:43:10
Hi everyone,

I'm new to the forum, this is my first post. I'm also new to the IC Imaging Control C++ Class Library, and programming in C++ in general. So, here's my question:

The following lines

DShowLib::Grabber::tVideoCaptureDeviceItem currentCaptureDevice = m_pGrabber->getDev();
*m_pCurrentVideoCaptureDevice = currentCaptureDevice.c_str();

produce error C2678: binary '==' : no operator found which takes a left-hand operand of type 'DShowLib::VideoCaptureDeviceItem' (or there is no acceptable conversion) c:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility 3078 1

I am not sure how xutility.h comes into play, but I think I will not want to mess with this one. Any ideas?

Regards,
Michael

Stefan Geissler
December 3, 2015, 16:06:09
Hello

VideoCaptureDeviceItem type is not a char*. char* is returned by currentCaptureDevice.c_str();

Why do not try

*m_pCurrentVideoCaptureDevice = m_pGrabber->getDev();

However, I do not know the complete context, therefore I need to guess.

Michen
December 4, 2015, 09:32:28
Hello

VideoCaptureDeviceItem type is not a char*. char* is returned by currentCaptureDevice.c_str();

Why do not try

*m_pCurrentVideoCaptureDevice = m_pGrabber->getDev();

However, I do not know the complete context, therefore I need to guess.

I'm sorry, I forgot to mention: *m_pCurrentVideoCaptureDevice is a pointer to a Cstring. Therefore it should work, shouldn't it? The context is that I need to fill a MFC-style Combo Box, which looks something like this:

void CDeviceDlg::DoComboBoxes()
{
// Select the current capture device in the combo box.
CComboBox* pCBox = (CComboBox*) GetDlgItem( IDC_VSOURCE_COMBO );
int cSel=pCBox->GetCurSel();

CString text;
int i;
GetDlgItemText( IDC_VSOURCE_COMBO, text );
DShowLib::Grabber::tVidCapDevListPtr pVidCapDevList = m_pGrabber->getAvailableVideoCaptureDevices();

if ( pVidCapDevList == NULL ) return;

i=std::count( pVidCapDevList->begin(), pVidCapDevList->end(), text );

if (i==0 && !pVidCapDevList->empty())
{
// The selected grabber has been removed (ie. is unplugged).
// Rebuild the video source list.
DoVSourceCombo();

DoComboBoxes();
return;
} else if (!pVidCapDevList->empty())
{
DShowLib::Grabber::tVidCapDevListPtr::value_type:: iterator it =
std::find( pVidCapDevList->begin(), pVidCapDevList->end(), text );

m_pGrabber->openDev( *it );

if(m_pGrabber->getLastError()) AfxMessageBox(m_pGrabber->getLastError());
DShowLib::Grabber::tVideoCaptureDeviceItem currentCaptureDevice = m_pGrabber->getDev();
*m_pCurrentVideoCaptureDevice = currentCaptureDevice.c_str();

if(m_pGrabber->getLastError()) AfxMessageBox(m_pGrabber->getLastError());

} else {

CComboBox* pCBox = (CComboBox*) GetDlgItem( IDC_VSOURCE_COMBO );
pCBox->EnableWindow( true );
CString notavailable="n/a";
pCBox->AddString( notavailable );
pCBox->SetCurSel( 0 );
pCBox = (CComboBox*) GetDlgItem( IDC_ICHANNEL_COMBO );
pCBox->EnableWindow( false );
pCBox = (CComboBox*) GetDlgItem( IDC_VFORMAT_COMBO );
pCBox->EnableWindow( false );
pCBox = (CComboBox*) GetDlgItem( IDC_VNORM_COMBO );
pCBox->EnableWindow( false );
}

This is source code that has been written about ten years ago, and I am currently trying to migrate to a VS2013 solution with the newer libraries. I think back then the author used IC Imaging Control 1.x ...

Michen

Michen
December 4, 2015, 10:33:07
Hello

VideoCaptureDeviceItem type is not a char*. char* is returned by currentCaptureDevice.c_str();

Why do not try

*m_pCurrentVideoCaptureDevice = m_pGrabber->getDev();

However, I do not know the complete context, therefore I need to guess.

Further investigations in this matter led me to believe that the problem lies elsewhere. I am still unable to figure out from which point xutility.h is invoked. Without knowing, I am unable to pinpoint the line of code that causes the error.
I usually double-click the error line in VS's error list to directly get to the corresponding code throwing the error. However, I am always redirected to xutility.h. What can I do?

Regards,
Michen

Stefan Geissler
December 4, 2015, 11:03:01
m_pGrabber->getDev(); returns a std::string.

If you want to have a char* you must call
m_pGrabber->getDev().c_str();

The char* can be passed to a CString.

Michen
December 4, 2015, 11:13:34
I understand. Nevertheless, if I

std::string currentCaptureDevice = m_pGrabber->getDev();

Intellisense tells me there is no suitable user-defined conversion from DShowLib::Grabber:tVideoCaptureDeviceItem to std::string.

Stefan Geissler
December 4, 2015, 12:09:37
ok, got it.

getDev() returns are video capture device item. Not a string. So what about

m_pGrabber->getDev().getName().c_str();

Please see:
http://www.theimagingsource.com/en_US/support/documentation/icimagingcontrol-class/meth_descVideoCaptureDeviceItem_getName.htm

Michen
December 4, 2015, 12:34:34
ok, got it.

getDev() returns are video capture device item. Not a string. So what about

m_pGrabber->getDev().getName().c_str();

Please see:
http://www.theimagingsource.com/en_US/support/documentation/icimagingcontrol-class/meth_descVideoCaptureDeviceItem_getName.htm

Going with your suggestion, the compiler comes up with a bunch of subsequent faults:

Error 30 error C2678: binary '==' : no operator found which takes a left-hand operand of type 'DShowLib::VideoCaptureDeviceItem' (or there is no acceptable conversion) c:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility 3078 1 Augen
Error 39 error C2678: binary '==' : no operator found which takes a left-hand operand of type 'DShowLib::VideoNormItem' (or there is no acceptable conversion) c:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility 3026 1 Augen
Error 40 error C2678: binary '==' : no operator found which takes a left-hand operand of type 'DShowLib::VideoFormatItem' (or there is no acceptable conversion) c:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility 3026 1 Augen
Error 41 error C2678: binary '==' : no operator found which takes a left-hand operand of type 'DShowLib::AnalogChannelItem' (or there is no acceptable conversion) c:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility 3026 1 Augen

I cannot resolve this..

Stefan Geissler
December 4, 2015, 15:56:50
I must admit, I do not see a "==" in the code. I wonder what happens on your system.

Also I am not sure, whether I distributed the "." and "->" correctly. You Intellisense should let you know, whether this is correct.

BTW: getDev().c_str() should have worked to, as shown in the IC Imaging Control 3.4 documentation

Michen
December 7, 2015, 10:41:25
I must admit, I do not see a "==" in the code. I wonder what happens on your system.

Also I am not sure, whether I distributed the "." and "->" correctly. You Intellisense should let you know, whether this is correct.

BTW: getDev().c_str() should have worked to, as shown in the IC Imaging Control 3.4 documentation

Indeed, that comparison is caused by xutility.h (which I mentioned in the beginning). It must be somehow invoked by one of your Control Classes. I wouldn't know how else it came into play. The exact line in xutility.h causing trouble is:

if (*_First == _Val)

... and the corresponding context is:

// TEMPLATE FUNCTION count
template<class _InIt,
class _Ty> inline
typename iterator_traits<_InIt>::difference_type
_Count_np(_InIt _First, _InIt _Last, const _Ty& _Val)
{ // count elements that match _Val
typename iterator_traits<_InIt>::difference_type _Count = 0;

for (; _First != _Last; ++_First)
if (*_First == _Val)
++_Count;
return (_Count);
}

Stefan Geissler
December 7, 2015, 10:57:51
If you only want to add a string to a combo box, you can use
m_cboDevice.AddString( CString( it->c_str() ) );

It seems, you want to rebuild the device selection dialog. You can make your live very easy, if you use the built in dialogs:
Grabber::showDevicePage()

http://www.theimagingsource.com/en_US/support/documentation/icimagingcontrol-class/meth_descGrabber_showDevicePage.htm

and for properties:
Grabber::showVCDPropertyPage()
http://www.theimagingsource.com/en_US/support/documentation/icimagingcontrol-class/meth_descGrabber_showVCDPropertyPage.htm

Michen
December 7, 2015, 11:18:29
If you only want to add a string to a combo box, you can use
m_cboDevice.AddString( CString( it->c_str() ) );

It seems, you want to rebuild the device selection dialog. You can make your live very easy, if you use the built in dialogs:
Grabber::showDevicePage()

http://www.theimagingsource.com/en_US/support/documentation/icimagingcontrol-class/meth_descGrabber_showDevicePage.htm

and for properties:
Grabber::showVCDPropertyPage()
http://www.theimagingsource.com/en_US/support/documentation/icimagingcontrol-class/meth_descGrabber_showVCDPropertyPage.htm

Thanks, I'll try this right away.

Regards,
Michen

Michen
December 7, 2015, 12:08:56
Thanks, I'll try this right away.

Regards,
Michen

Interesting news, I finally found the lines causing the error. They're in the DeviceDlg.h file. Before rewriting , I thought I might also ask again for a possible solution. Here's the code:


#if !defined(AFX_DEVICEDLG_H__A7BAF7AD_CD0A_4EF7_9DCB_ 2F35603F8CD4__INCLUDED_)
#define AFX_DEVICEDLG_H__A7BAF7AD_CD0A_4EF7_9DCB_2F35603F8 CD4__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DeviceDlg.h : header file
//

#include "TISUDSHL.h"
#include "resource.h"
/////////////////////////////////////////////////////////////////////////////
// CDeviceDlg dialog

class CDeviceDlg : public CDialog
{
// Construction
public:
CDeviceDlg(DShowLib::Grabber* pGrabber, BOOL *AutoWindowResize
,CString *CurrentVideoCaptureDevice, CWnd* pParent = NULL);

// Dialog Data
//{{AFX_DATA(CDeviceDlg)
enum { IDD = IDD_DEVICE_DIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA


// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDeviceDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:

// Generated message map functions
//{{AFX_MSG(CDeviceDlg)
afx_msg void OnWndSizeCheck();
virtual BOOL OnInitDialog();
afx_msg void OnSelchangeIchannelCombo();
afx_msg void OnSelchangeVformatCombo();
afx_msg void OnSelchangeVnormCombo();
afx_msg void OnSelchangeVsourceCombo();
virtual void OnCancel();
virtual void OnOK();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()

private:
void DoComboBoxes();
void DoFormatCombo();
void DoVSourceCombo();

------------------------------------ HERE --------------------------------

DShowLib::Grabber* m_pGrabber;
DShowLib::Grabber::tVideoNormItem m_VideoNorm;
DShowLib::Grabber::tVideoFormatItem m_VideoFormat;
//DShowLib::Grabber::tVideoCaptureDeviceItem m_CurrentVideoCaptureDevice;
DWORD m_InputChannel;
BOOL* m_pAutoWindowResize;
CString* m_pCurrentVideoCaptureDevice;

DShowLib::Grabber::tVideoNormItem m_OldVideoNorm;
DShowLib::Grabber::tVideoFormatItem m_OldVideoFormat;
DWORD m_OldInputChannel;
BOOL m_OldAutoWindowResize;
CString m_OldVideoCaptureDevice;
// DShowLib::Grabber::tVideoCaptureDeviceItem m_OldVideoCaptureDevice;
};

--------------------------------------- HERE ---------------------------------------

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_DEVICEDLG_H__A7BAF7AD_CD0A_4EF7_9DCB_ 2F35603F8CD4__INCLUDED_)

Michen
December 7, 2015, 12:37:51
Please excuse all this back-and-forth, but the header file is not the problem. The comparison actually *DOES* happen in my code.
Right here:

if ( std::count(pVidNrmList->begin(), pVidNrmList->end(), m_VideoNorm) == 0 )

std::count must be what invokes xutility.h

Any suggestions? I still find it very awkward why the compiler error does not direct me to this line. It seems to me like seeking needles in the hay. Or maybe it's just me.

Stefan Geissler
December 7, 2015, 13:38:45
What is "m_VideoNorm"? Make sure, it is the same type of pVidNrmList->begin() returns, otherwise the compare will fail.