<commit_before>/*
 * light_detection_node.cpp
 *
 *  Created on: Oct 3, 2016
 *      Author: oakyildiz, <NAME>
 *		 Email: <EMAIL>
 *
 */

#include "vision/vision.h"

bool IS_STEREO = true;
bool IS_WEBCAM = false;
bool safe = false;

std::string CAMERA_NAMESPACE = "/multisense/camera";
std::string IMAGE_TYPE;



using namespace vision;
/* Node */
VisionNode::VisionNode(VisionModule* module, int argc, char** argv):
			Node(argc,argv),
			module(module),
			it_(0)
{
	}


void VisionNode::setupParams() {
	it_ = new image_transport::ImageTransport(*nh_);
	pnh_->param<bool>("stereo", IS_STEREO, IS_STEREO); // lets  default param values to
	pnh_->param<bool>("webcam", IS_WEBCAM,IS_WEBCAM);  // source ode's variable valeus

	pnh_->param<std::string>("image",IMAGE_TYPE,"image_raw");

	//pnh_->param<NodeType>("node_type", NODE_TYPE,LIGHT);
	pnh_->param<std::string>("camera_namespace",CAMERA_NAMESPACE,"/multisense/camera");

	/*overrides*/

}
void VisionNode::setupCustom(){
if(IMAGE_TYPE != "image_raw") IMAGE_TYPE = "image_raw/" + IMAGE_TYPE;
	/*subs and pubs*/
	std::string info="camera_info";

	if(IS_WEBCAM){
		IS_STEREO = false;	// for now, we override stereo
							// to false if webcam is used.
		CAMERA_NAMESPACE = "/usb_cam"; //TODO: change how this is handled.
		mono_camera_sub = it_-> subscribe(CAMERA_NAMESPACE + "/" + IMAGE_TYPE, 100, &VisionNode::visionCallback, this);
		mono_info_sub = nh_-> subscribe(CAMERA_NAMESPACE + "/" + info, 100, &VisionNode::camereInfoCallback, this);

	}
	else{
		left_camera_sub = it_-> subscribe(CAMERA_NAMESPACE + "/left/"+ IMAGE_TYPE, 100, &VisionNode::visionCallback, this);
		left_info_sub = pnh_-> subscribe(CAMERA_NAMESPACE + "/left/"+ info, 100, &VisionNode::camereInfoCallback, this);

		if(IS_STEREO){
			right_camera_sub = it_-> subscribe(CAMERA_NAMESPACE + "/right/"+ IMAGE_TYPE, 1000, &VisionNode::disparityCallback, this);
			right_info_sub = nh_-> subscribe(CAMERA_NAMESPACE + "/right/"+ info, 100, &VisionNode::camereInfoCallback, this);

		}<commit_msg>Update vision.cpp<commit_after>/*
 * light_detection_node.cpp
 *
 *  Created on: Oct 3, 2016
 *      Author: oakyildiz, <NAME>
 *		 Email: <EMAIL>
 *
 */

#include "vision/vision.h"

/*ros_parameters for camera hardware */
bool IS_STEREO = true;
bool IS_WEBCAM = false;
bool safe = false; //flag for camera images being ready to process

std::string CAMERA_NAMESPACE = "/multisense/camera";
std::string IMAGE_TYPE;



using namespace vision;
/* Node */
VisionNode::VisionNode(VisionModule* module, int argc, char** argv):
			Node(argc,argv),
			module(module),
			it_(0)
{
	}

//define abstract function from Node to add vision parameters
void VisionNode::setupParams() {
	it_ = new image_transport::ImageTransport(*nh_);
	pnh_->param<bool>("stereo", IS_STEREO, IS_STEREO); // lets  default param values to
	pnh_->param<bool>("webcam", IS_WEBCAM,IS_WEBCAM);  // source code's variable valeus

	pnh_->param<std::string>("image",IMAGE_TYPE,"image_raw");

	//pnh_->param<NodeType>("node_type", NODE_TYPE,LIGHT);
	pnh_->param<std::string>("camera_namespace",CAMERA_NAMESPACE,"/multisense/camera");

	/*overrides*/

}
void VisionNode::setupCustom(){
if(IMAGE_TYPE != "image_raw") IMAGE_TYPE = "image_raw/" + IMAGE_TYPE;
	/*subs and pubs*/
	std::string info="camera_info";
	
	if(IS_WEBCAM){
		IS_STEREO = false;	// for now, we override stereo
							// to false if webcam is used.
		CAMERA_NAMESPACE = "/usb_cam"; //TODO: change how this is handled.
		mono_camera_sub = it_-> subscribe(CAMERA_NAMESPACE + "/" + IMAGE_TYPE, 100, &VisionNode::visionCallback, this);
		mono_info_sub = nh_-> subscribe(CAMERA_NAMESPACE + "/" + info, 100, &VisionNode::camereInfoCallback, this);

	}
	else{
		left_camera_sub = it_-> subscribe(CAMERA_NAMESPACE + "/left/"+ IMAGE_TYPE, 100, &VisionNode::visionCallback, this);
		left_info_sub = pnh_-> subscribe(CAMERA_NAMESPACE + "/left/"+ info, 100, &VisionNode::camereInfoCallback, this);

		if(IS_STEREO){
			right_camera_sub = it_-> subscribe(CAMERA_NAMESPACE + "/right/"+ IMAGE_TYPE, 1000, &VisionNode::disparityCallback, this);
			right_info_sub = nh_-> subscribe(CAMERA_NAMESPACE + "/right/"+ info, 100, &VisionNode::camereInfoCallback, this);

		}
{'fraction_non_alphanumeric': 0.15415773171312844, 'fraction_numerical': 0.011913271384322134, 'mean_word_length': 5.128467153284672, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6411376', 'n_tokens_mistral': 1624, 'n_tokens_neox': 1522, 'n_words': 316}