260 |
260 |
DC1394_FEATURE_TEMPERATURE, //CV_CAP_PROP_TEMPERATURE
|
261 |
261 |
DC1394_FEATURE_TRIGGER, //CV_CAP_PROP_TRIGGER
|
262 |
262 |
DC1394_FEATURE_TRIGGER_DELAY, //CV_CAP_PROP_TRIGGER_DELAY
|
263 |
|
DC1394_FEATURE_WHITE_BALANCE//CV_CAP_PROP_WHITE_BALANCE_RED_V
|
|
263 |
//GH --->
|
|
264 |
DC1394_FEATURE_WHITE_BALANCE,//CV_CAP_PROP_WHITE_BALANCE_RED_V
|
|
265 |
DC1394_FEATURE_ZOOM, //CV_CAP_PROP_ZOOM
|
|
266 |
DC1394_FEATURE_FOCUS, //CV_CAP_PROP_FOCUS
|
|
267 |
-1 //CV_CAP_PROP_GUID
|
|
268 |
//GH <---
|
264 |
269 |
};
|
265 |
270 |
CvCaptureCAM_DC1394_v2_CPP::CvCaptureCAM_DC1394_v2_CPP()
|
266 |
271 |
{
|
... | ... | |
303 |
308 |
DC1394_ISO_SPEED_3200);
|
304 |
309 |
}
|
305 |
310 |
|
|
311 |
|
|
312 |
//GH --->
|
|
313 |
// should a specific mode be used
|
|
314 |
if (userMode >= 0)
|
|
315 |
{
|
|
316 |
dc1394video_mode_t wantedMode;
|
|
317 |
dc1394video_modes_t videoModes;
|
|
318 |
dc1394_video_get_supported_modes(dcCam, &videoModes);
|
|
319 |
|
|
320 |
//set mode from number, for example the second supported mode, i.e userMode = 1
|
|
321 |
if (userMode < (int)videoModes.num)
|
|
322 |
{
|
|
323 |
wantedMode = videoModes.modes[userMode];
|
|
324 |
}
|
|
325 |
|
|
326 |
//set modes directly from DC134 constants (from dc1394video_mode_t)
|
|
327 |
else if ((userMode >= DC1394_VIDEO_MODE_MIN) && (userMode <= DC1394_VIDEO_MODE_MAX ))
|
|
328 |
{
|
|
329 |
//search for wanted mode, to check if camera supports it
|
|
330 |
int j = 0;
|
|
331 |
while ((j< (int)videoModes.num) && videoModes.modes[j]!=userMode)
|
|
332 |
{
|
|
333 |
j++;
|
|
334 |
}
|
|
335 |
if ((int)videoModes.modes[j]==userMode)
|
|
336 |
{
|
|
337 |
wantedMode = videoModes.modes[j];
|
|
338 |
}
|
|
339 |
else
|
|
340 |
{
|
|
341 |
userMode = -1; // wanted mode not supported, search for best mode
|
|
342 |
}
|
|
343 |
}
|
|
344 |
else
|
|
345 |
{
|
|
346 |
userMode = -1; // wanted mode not supported, search for best mode
|
|
347 |
}
|
|
348 |
|
|
349 |
//if userMode is available: set it and update size
|
|
350 |
if (userMode != -1)
|
|
351 |
{
|
|
352 |
code = dc1394_video_set_mode(dcCam, wantedMode);
|
|
353 |
uint32_t width, height;
|
|
354 |
dc1394_get_image_size_from_video_mode(dcCam, wantedMode, &width, &height);
|
|
355 |
frameWidth = (int)width;
|
|
356 |
frameHeight = (int)height;
|
|
357 |
}
|
|
358 |
}
|
|
359 |
//GH <---
|
|
360 |
|
|
361 |
// search for best mode
|
306 |
362 |
if (userMode == -1 && (frameWidth > 0 || frameHeight > 0))
|
307 |
363 |
{
|
308 |
364 |
dc1394video_mode_t bestMode = (dc1394video_mode_t) - 1;
|
... | ... | |
311 |
367 |
for (i = 0; i < (int)videoModes.num; i++)
|
312 |
368 |
{
|
313 |
369 |
dc1394video_mode_t mode = videoModes.modes[i];
|
314 |
|
if (mode >= DC1394_VIDEO_MODE_FORMAT7_MIN && mode <= DC1394_VIDEO_MODE_FORMAT7_MAX)
|
315 |
|
continue;
|
|
370 |
if (mode >= DC1394_VIDEO_MODE_FORMAT7_MIN && mode <= DC1394_VIDEO_MODE_FORMAT7_MAX)
|
|
371 |
continue;
|
316 |
372 |
int pref = -1;
|
317 |
373 |
dc1394color_coding_t colorCoding;
|
318 |
374 |
dc1394_get_color_coding_from_video_mode(dcCam, mode, &colorCoding);
|
... | ... | |
348 |
404 |
code = dc1394_video_set_mode(dcCam, bestMode);
|
349 |
405 |
}
|
350 |
406 |
|
351 |
|
if (userMode > 0)
|
352 |
|
{
|
353 |
|
dc1394video_modes_t videoModes;
|
354 |
|
dc1394_video_get_supported_modes(dcCam, &videoModes);
|
355 |
|
if (userMode < (int)videoModes.num)
|
356 |
|
{
|
357 |
|
dc1394video_mode_t mode = videoModes.modes[userMode];
|
358 |
|
code = dc1394_video_set_mode(dcCam, mode);
|
359 |
|
}
|
360 |
|
}
|
361 |
407 |
|
362 |
408 |
if (fps > 0)
|
363 |
409 |
{
|
... | ... | |
619 |
665 |
&feature_set.feature[DC1394_FEATURE_WHITE_BALANCE-DC1394_FEATURE_MIN].RV_value) == DC1394_SUCCESS)
|
620 |
666 |
return feature_set.feature[DC1394_FEATURE_WHITE_BALANCE-DC1394_FEATURE_MIN].RV_value;
|
621 |
667 |
break;
|
|
668 |
//GH --->
|
|
669 |
case CV_CAP_PROP_GUID:
|
|
670 |
//the least 32 bits are enough to identify the camera
|
|
671 |
return (double) (guid & 0x00000000FFFFFFFF);
|
|
672 |
break;
|
|
673 |
case CV_CAP_PROP_MODE:
|
|
674 |
return (double) userMode;
|
|
675 |
break;
|
|
676 |
case CV_CAP_PROP_ISO_SPEED:
|
|
677 |
return (double) isoSpeed;
|
|
678 |
|
622 |
679 |
default:
|
623 |
|
if (propId<CV_CAP_PROP_MAX_DC1394 && dc1394properties[propId]!=-1
|
624 |
|
&& dcCam)
|
625 |
|
//&& feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN].on_off_capable)
|
626 |
|
if (dc1394_feature_get_value(dcCam,(dc1394feature_t)dc1394properties[propId],
|
627 |
|
&feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN].value) == DC1394_SUCCESS)
|
628 |
|
return feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN].value;
|
|
680 |
if (propId<CV_CAP_PROP_MAX_DC1394 && dc1394properties[propId]!=-1 && dcCam)
|
|
681 |
|
|
682 |
//check read-capable
|
|
683 |
if (feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN].readout_capable)
|
|
684 |
{
|
|
685 |
if (dc1394_feature_get_value(
|
|
686 |
dcCam,
|
|
687 |
(dc1394feature_t)dc1394properties[propId],
|
|
688 |
&feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN].value
|
|
689 |
)
|
|
690 |
== DC1394_SUCCESS
|
|
691 |
)
|
|
692 |
return feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN].value;
|
|
693 |
}
|
|
694 |
//GH <---
|
629 |
695 |
}
|
630 |
696 |
return -1; // the value of the feature can be 0, so returning 0 as an error is wrong
|
631 |
697 |
}
|
... | ... | |
648 |
714 |
break;
|
649 |
715 |
case CV_CAP_PROP_FPS:
|
650 |
716 |
if(started)
|
651 |
|
return false;
|
652 |
|
fps = value;
|
653 |
|
break;
|
|
717 |
return false;
|
|
718 |
fps = value;
|
|
719 |
break;
|
654 |
720 |
case CV_CAP_PROP_RECTIFICATION:
|
655 |
721 |
if( cameraId != VIDERE )
|
656 |
722 |
return false;
|
657 |
723 |
rectify = fabs(value) > FLT_EPSILON;
|
658 |
724 |
break;
|
659 |
725 |
case CV_CAP_PROP_MODE:
|
|
726 |
if(started)
|
|
727 |
return false;
|
660 |
728 |
userMode = cvRound(value);
|
|
729 |
break;
|
|
730 |
case CV_CAP_PROP_ISO_SPEED:
|
|
731 |
if(started)
|
|
732 |
return false;
|
|
733 |
isoSpeed = cvRound(value);
|
661 |
734 |
break;
|
662 |
735 |
//The code below is based on coriander, callbacks.c:795, refer to case RANGE_MENU_MAN :
|
663 |
736 |
default:
|
664 |
|
if (propId<CV_CAP_PROP_MAX_DC1394 && dc1394properties[propId]!=-1
|
665 |
|
&& dcCam)
|
|
737 |
|
|
738 |
//GH --->
|
|
739 |
if (propId<CV_CAP_PROP_MAX_DC1394 && dc1394properties[propId]!=-1 && dcCam)
|
666 |
740 |
{
|
|
741 |
//get the corresponding feature from property-id
|
|
742 |
dc1394feature_info_t *act_feature = &feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN];
|
|
743 |
|
667 |
744 |
if (cvRound(value) == CV_CAP_PROP_DC1394_OFF)
|
668 |
745 |
{
|
669 |
|
if ((feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN].on_off_capable)
|
670 |
|
&& (dc1394_feature_set_power(dcCam, (dc1394feature_t)dc1394properties[propId], DC1394_OFF)==DC1394_SUCCESS))
|
|
746 |
if ( (act_feature->on_off_capable)
|
|
747 |
&& (dc1394_feature_set_power(dcCam, act_feature->id, DC1394_OFF) == DC1394_SUCCESS))
|
671 |
748 |
{
|
672 |
|
feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN].is_on=DC1394_OFF;
|
|
749 |
act_feature->is_on=DC1394_OFF;
|
673 |
750 |
return true;
|
674 |
751 |
}
|
675 |
752 |
return false;
|
676 |
753 |
}
|
|
754 |
|
677 |
755 |
//try to turn the feature ON, feature can be ON and at the same time it can be not capable to change state to OFF
|
678 |
|
if ( feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN].is_on == DC1394_OFF &&
|
679 |
|
(feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN].on_off_capable == DC1394_TRUE))
|
|
756 |
if ( (act_feature->is_on == DC1394_OFF) && (act_feature->on_off_capable == DC1394_TRUE))
|
680 |
757 |
{
|
681 |
|
if (dc1394_feature_set_power(dcCam, (dc1394feature_t)dc1394properties[propId], DC1394_ON) == DC1394_SUCCESS)
|
682 |
|
feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN].is_on=DC1394_ON;
|
|
758 |
if (dc1394_feature_set_power(dcCam, act_feature->id, DC1394_ON) == DC1394_SUCCESS)
|
|
759 |
act_feature->is_on=DC1394_ON;
|
683 |
760 |
}
|
|
761 |
|
684 |
762 |
//turn off absolute mode - the actual value will be stored in the value field,
|
685 |
763 |
//otherwise it would be stored into CSR (control and status register) absolute value
|
686 |
|
if (feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN].absolute_capable
|
687 |
|
&& dc1394_feature_set_absolute_control(dcCam, (dc1394feature_t)dc1394properties[propId], DC1394_OFF) !=DC1394_SUCCESS)
|
|
764 |
if (act_feature->absolute_capable
|
|
765 |
&& dc1394_feature_set_absolute_control(dcCam, act_feature->id, DC1394_OFF) !=DC1394_SUCCESS)
|
688 |
766 |
return false;
|
689 |
767 |
else
|
690 |
|
feature_set.feature[(dc1394feature_t)dc1394properties[propId]-DC1394_FEATURE_MIN].abs_control=DC1394_OFF;
|
|
768 |
act_feature->abs_control=DC1394_OFF;
|
|
769 |
|
691 |
770 |
//set AUTO
|
692 |
771 |
if (cvRound(value) == CV_CAP_PROP_DC1394_MODE_AUTO)
|
693 |
772 |
{
|
694 |
|
if (dc1394_feature_set_mode(dcCam, (dc1394feature_t)dc1394properties[propId], DC1394_FEATURE_MODE_AUTO)!=DC1394_SUCCESS)
|
|
773 |
if (dc1394_feature_set_mode(dcCam, act_feature->id, DC1394_FEATURE_MODE_AUTO)!=DC1394_SUCCESS)
|
695 |
774 |
return false;
|
696 |
|
feature_set.feature[(dc1394feature_t)dc1394properties[propId]-DC1394_FEATURE_MIN].current_mode=DC1394_FEATURE_MODE_AUTO;
|
|
775 |
act_feature->current_mode=DC1394_FEATURE_MODE_AUTO;
|
697 |
776 |
return true;
|
698 |
777 |
}
|
|
778 |
|
699 |
779 |
//set ONE PUSH
|
700 |
780 |
if (cvRound(value) == CV_CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO)
|
701 |
781 |
{
|
702 |
782 |
//have to set to manual first, otherwise one push will be ignored (AVT manual 4.3.0 p. 115)
|
703 |
|
if (dc1394_feature_set_mode(dcCam, (dc1394feature_t)dc1394properties[propId], DC1394_FEATURE_MODE_ONE_PUSH_AUTO)!=DC1394_SUCCESS)
|
|
783 |
if (dc1394_feature_set_mode(dcCam, act_feature->id, DC1394_FEATURE_MODE_ONE_PUSH_AUTO)!=DC1394_SUCCESS)
|
704 |
784 |
return false;
|
705 |
785 |
//will change to
|
706 |
|
feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN].current_mode=DC1394_FEATURE_MODE_ONE_PUSH_AUTO;
|
|
786 |
act_feature->current_mode=DC1394_FEATURE_MODE_ONE_PUSH_AUTO;
|
707 |
787 |
return true;
|
708 |
788 |
}
|
|
789 |
|
709 |
790 |
//set the feature to MANUAL mode,
|
710 |
|
if (dc1394_feature_set_mode(dcCam, (dc1394feature_t)dc1394properties[propId], DC1394_FEATURE_MODE_MANUAL)!=DC1394_SUCCESS)
|
|
791 |
if (dc1394_feature_set_mode(dcCam, act_feature->id, DC1394_FEATURE_MODE_MANUAL)!=DC1394_SUCCESS)
|
711 |
792 |
return false;
|
712 |
793 |
else
|
713 |
|
feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN].current_mode=DC1394_FEATURE_MODE_MANUAL;
|
|
794 |
act_feature->current_mode=DC1394_FEATURE_MODE_MANUAL;
|
|
795 |
|
714 |
796 |
// if property is one of the white balance features treat it in different way
|
715 |
797 |
if (propId == CV_CAP_PROP_WHITE_BALANCE_BLUE_U)
|
716 |
798 |
{
|
717 |
|
if (dc1394_feature_whitebalance_set_value(dcCam,cvRound(value), feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN].RV_value)!=DC1394_SUCCESS)
|
|
799 |
if (dc1394_feature_whitebalance_set_value(dcCam,cvRound(value), act_feature->RV_value)!=DC1394_SUCCESS)
|
718 |
800 |
return false;
|
719 |
801 |
else
|
720 |
802 |
{
|
721 |
|
feature_set.feature[DC1394_FEATURE_WHITE_BALANCE-DC1394_FEATURE_MIN].BU_value = cvRound(value);
|
|
803 |
act_feature->BU_value = cvRound(value);
|
722 |
804 |
return true;
|
723 |
805 |
}
|
724 |
806 |
}
|
725 |
807 |
if (propId == CV_CAP_PROP_WHITE_BALANCE_RED_V)
|
726 |
808 |
{
|
727 |
|
if (dc1394_feature_whitebalance_set_value(dcCam,feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN].BU_value,cvRound(value))!=DC1394_SUCCESS)
|
|
809 |
if (dc1394_feature_whitebalance_set_value(dcCam,act_feature->BU_value,cvRound(value))!=DC1394_SUCCESS)
|
728 |
810 |
return false;
|
729 |
811 |
else
|
730 |
812 |
{
|
731 |
|
feature_set.feature[DC1394_FEATURE_WHITE_BALANCE-DC1394_FEATURE_MIN].RV_value = cvRound(value);
|
|
813 |
act_feature->RV_value = cvRound(value);
|
732 |
814 |
return true;
|
733 |
815 |
}
|
734 |
816 |
}
|
|
817 |
|
735 |
818 |
// finally set the feature
|
736 |
|
if (dc1394_feature_set_value(dcCam,(dc1394feature_t)dc1394properties[propId],cvRound(value)) == DC1394_SUCCESS)
|
|
819 |
|
|
820 |
//first: check boundaries
|
|
821 |
if (value < act_feature->min)
|
737 |
822 |
{
|
738 |
|
feature_set.feature[dc1394properties[propId]-DC1394_FEATURE_MIN].value = value;
|
|
823 |
value = act_feature->min;
|
|
824 |
}
|
|
825 |
else if (value > act_feature->max)
|
|
826 |
{
|
|
827 |
value = act_feature->max;
|
|
828 |
}
|
|
829 |
|
|
830 |
if (dc1394_feature_set_value(dcCam,act_feature->id,cvRound(value)) == DC1394_SUCCESS)
|
|
831 |
{
|
|
832 |
act_feature->value = value;
|
739 |
833 |
return true;
|
740 |
834 |
}
|
741 |
835 |
}
|
742 |
836 |
return false;
|
|
837 |
|
743 |
838 |
}
|
744 |
839 |
return true;
|
745 |
840 |
}
|